ExoPlayer icon indicating copy to clipboard operation
ExoPlayer copied to clipboard

Change SimpleExoPlayerView and not display smooth

Open walksin opened this issue 9 years ago • 8 comments

When I use demo, I add some code at onConfigurationChanged to switch play in different SimpleExoPlayerView, the code is

if(newConfig.orientation == ORIENTATION_LANDSCAPE){
  simpleExoPlayerView.setPlayer(null);
  player_view_full.setVisibility(View.VISIBLE);
  player_view_full.setPlayer(player);
}else{
  player_view_full.setVisibility(View.GONE);
  player_view_full.setPlayer(null);
  simpleExoPlayerView.setPlayer(player);
}

It show like this when I switch it to new SimpleExoPlayerView image

And seconds later, it renders correctly, the screenshot is below: image

I try it on more than 3 devices, they all act same,include NEXUS 6

my question is how to switch SimpleExoPlayerView correctly, and how to avoid the bad render experience in the first seconds, thank you.

walksin avatar Feb 12 '17 16:02 walksin

I think this is fixed in r2.2.0. If you believe otherwise, please file a new issue including all of the information clearly requested in the issue template, since there is not enough information provided here for us to assist.

ojw28 avatar Feb 13 '17 04:02 ojw28

Thank you for your fast reply :)

I try it on r2.2.0 and image won't be fuzzy, it's great!

But there is a video render problem. When I switch, Image keeps still about seconds then start move,from the debug info, it tells that the video's renderedOutputBufferCount stop rising about seconds while audio's renderedOutputBufferCount keep rising.

How can I get a smooth switch SimpleExoPlayerView and won't be any video render image delay?

walksin avatar Feb 13 '17 07:02 walksin

You can read a bit about why it's (unfortunately) difficult to do what you're trying to do in https://github.com/google/ExoPlayer/issues/2093, https://github.com/google/ExoPlayer/issues/1084 and https://github.com/google/ExoPlayer/issues/318. If possible you should handle the configuration change yourself as the demo app does, to avoid the problem. It's more work and you might have to do a bit of UI magic in code that would otherwise happen automatically, but it's possible. I'm fairly sure YouTube handles the orientation change itself, for example.

ojw28 avatar Feb 13 '17 14:02 ojw28

Thank you so much 👍

walksin avatar Feb 13 '17 15:02 walksin

Similar problem with r2.2.0. After surface destroy->create with the same surface view and when called setPlayWhenReady(false) -> setPlayWhenReady(true) ExoPlayer just render next keyframe (in our source it is after 10 seconds). All that time sound plays, but video freezed on that keyframe.

On version r2.1.0 video was with artefacts however.

Note: workaround to this problem is call seekTo just before setPlayWhenReady(true)

samoylenkodmitry avatar Feb 14 '17 17:02 samoylenkodmitry

i had the same problem. After surfaceview destroy->create with the same surfaceview .. sometimes, the SurfaceView will keep the frame when destory.

ghost avatar Feb 20 '17 10:02 ghost

I'm also facing same issue @s-a--m, have you got any solution?

thackerronak avatar Apr 06 '17 06:04 thackerronak

Finally I'm detected error happens when we call setPlayWhenReady before applying surface to player. Then after surface changed player stuck with old frame for some time.

So workaround would be call seek just after applying surface:

		final ExoPlayer.ExoPlayerMessage message = new ExoPlayer.ExoPlayerMessage(videoRenderer, C.MSG_SET_SURFACE, surface);
			player.blockingSendMessages(message);
			if (surface != null) {
				final long position = mPlayer.getCurrentPosition();
			
		/*
		Workaround ExoPlayer 2.2.0 bug
		https://github.com/google/ExoPlayer/issues/2441
		 */
				
				mPlayer.seekTo(position-1);
			}

samoylenkodmitry avatar May 22 '17 15:05 samoylenkodmitry