Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Play/pause should have different behavior at end of video #3689

Closed
eldad-evie opened this issue Jan 9, 2018 · 6 comments
Closed

Play/pause should have different behavior at end of video #3689

eldad-evie opened this issue Jan 9, 2018 · 6 comments
Assignees

Comments

@eldad-evie
Copy link

(I'm not sure if this qualifies as a bug or a feature request)

I'm running the sample app, and at the end of the video the pause/play button stops having any effect. The icon changes when tapped, but nothing else happens.

On YouTube, reaching the end of a video changes the button from play to a third state - replay. Pressing it seeks to the beginning and starts playback again. I think that makes for a far better user experience.

I've tried to accomplish the same thing with a PlaybackControlView.ControlDispatcher that checks the current time in dispatchSetPlayWhenReady() and if it's identical to the duration of the video, calls player.seekTo(0) then player.setPlayWhenReady(true) - this does jump back to the beginning of the video but a second press is required to actually start playback. What am I missing?

@marcbaechinger
Copy link
Contributor

marcbaechinger commented Jan 9, 2018

The current behaviour of the PlaybackControlView works as intended as it reflects the state of the player (playWhenReady=true and position at the very end).

Instead of providing your own dispatcher you could wait for the state Player.STATE_ENDED with a Player.EventListener and then do

player.setPlayWhenReady(false);
player.seekTo(C.TIME_UNSET);

Now the player state is playWhenReady=false an position=0 and the UI reflects this. When the user taps play it starts from the beginning.

Note, that the first frame of the video will be displayed at this stage.

@eldad-evie
Copy link
Author

eldad-evie commented Jan 10, 2018

Thank you. I understand your solution and see that it works, but I really feel that for many apps having the controls reflect the player state doesn't provide the best experience.

To get around the issue of jumping to the first frame, I think I can do something like this for my own apps at least:

  1. When onPlayerStateChanged receives the STATE_ENDED event, call setPlayWhenReady(false) to pause the video, and seek to just before the end (say, 10ms) - possibly not in this order.

  2. Set a dispatcher that, if dispatchSetPlayWhenReady is called when playWhenReady == true and the current position is just before the end, calls seekTo(0) before dispatching playWhenReady(true).

(I realize this is an ugly hack).

@ojw28
Copy link
Contributor

ojw28 commented Jan 10, 2018

@marcbaechinger - Do we have assets for a replay button already?

@marcbaechinger
Copy link
Contributor

Nope. I checked with the Material Design Icons and there is one when I search for 'replay'.

https://material.io/icons/

@ojw28
Copy link
Contributor

ojw28 commented Jan 10, 2018

It could also be valid (and possibly nicer) to use the play button for the replay case, rather than using the replay asset.

@ojw28 ojw28 changed the title Play/pause button stops working at end of video Play/pause should have different behavior at end of video Jan 11, 2018
@ojw28 ojw28 self-assigned this Jan 11, 2018
ojw28 added a commit that referenced this issue Jan 23, 2018
- In IDLE, the button will now call a preparer. This allows
  removal of the separate retry button from the demo app.
- In ENDED, the button will seek back to the default position
  and play.
- Behavior is made consistent with LeanbackPlayerAdapter.

Issue: #3689

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=182506855
@ojw28
Copy link
Contributor

ojw28 commented Jan 23, 2018

This is fixed in the dev-v2 branch. We now show the play button on ended, and pressing it will play from the default position of the current window (i.e. if you're just playing a single piece of on-demand content, it will start from the beginning).

@ojw28 ojw28 closed this as completed Jan 23, 2018
@google google locked and limited conversation to collaborators Jun 29, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants