ExoPlayer icon indicating copy to clipboard operation
ExoPlayer copied to clipboard

Detaching and reattaching ExoPlayer at end state does not show last frame

Open JessHolle opened this issue 3 years ago • 6 comments
trafficstars

If you let ExoPlayer play to the last frame of the video that frame will remain shown -- which is what we want.

While in that state if you detach the player view from the view hierarchy and re-attach it, however, you get a blank/black screen area rather than the last frame.

It seems that the "showing last frame" state should be retained/restored in this case.

(This issue is reproducible with 2.16.1, the latest ExoPlayer version at this time.)

JessHolle avatar Jan 24 '22 13:01 JessHolle

The last frame after playback remains shown on the surface after it has been rendered. When you attach the player to another surface (or re-attach and attach again) this frame would have to be rendered again. I think this is something else than keeping the last frame. So I don't share your expectation.

I can make the player render that frame again by seeking to the duration of the stream after having re-attached the player to the player view. So that may be an option for you to get the behaviour you want after re-attaching:

playerView.setPlayer(null);
playerView.setPlayer(player);
player.seekTo(player.getDuration());

marcbaechinger avatar Jan 24 '22 14:01 marcbaechinger

If one considers the technical details underlying the player, then, yes, I can see how the black screen might be expected.

As a someone just using the API and reparenting a branch of the view hierarchy containing a movie player, however, the behavior is rather unexpected and unhelpful.

Note that if you pause mid-video then this issue does not occur. It is specific to the last frame. I believe this inconsistency is surprising and undesirable.

JessHolle avatar Jan 24 '22 15:01 JessHolle

Note: This is basically the "last frame special case" of https://github.com/google/ExoPlayer/issues/5428.

ojw28 avatar Jan 24 '22 15:01 ojw28

Yes, seems like somewhat of a duplicate.

I would note that in the case at hand here the PlayerView is part of a whole view hierarchy that is being reparented. The high-level expectation would be that this just "works", i.e. reproduces the state from prior to reparenting the view hierarchy -- not that one has to delve into surfaceview details. (Also for other reasons texture_view mode is being used in our case.)

JessHolle avatar Jan 24 '22 16:01 JessHolle

Something worth noting is that you don't even have to let the player play until the last frame (STATE_ENDED) to see this!

If the player is paused, each time it's detached and reattached it will advance a frame (as described in #5428). So if you do this enough times, you'll eventually run out of frames and wind up with the blank view that @JessHolle described.

This makes the issue especially pernicious; how often/whether you can repro it depends on both (1) how many frames from the end you are when you pause the video and (2) how many times you cause the player to be re-attached (e.g. scroll it out of view and back).

matthewwithanm avatar Jul 09 '23 00:07 matthewwithanm

Any update on addressing this issue ?

ptc-rgrasset avatar Nov 28 '23 11:11 ptc-rgrasset