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

Add "play" and "pause" events #1253

Merged
merged 3 commits into from Jun 13, 2023
Merged

Add "play" and "pause" events #1253

merged 3 commits into from Jun 13, 2023

Conversation

peaBerberian
Copy link
Collaborator

As I've been working a lot more with application code (media player UIs) lately, I saw that a real concept of whether playback was playing or paused was missing in the RxPlayer API.

You could approximate it by getting the player's state, but some states, like "BUFFERING" or "LOADING", even if they indicate that playback is not happening right now, do not indicate whether we're actually paused or not.

For example, once the buffering period is over, will we play directly or still be paused? Or, after "LOADING", will we play or just be paused on the first loaded frame?

One area where this concept is central to an application is for example to know whether the "play/pause" button should currently play or pause, which also dictates what the button should look like: if we're playing, this is a pause button which will pause playback, if we're paused, it will be a play button starting playback - and this, regardless of the current player's state.


That's the reason the isPaused method (#1248) is planned for the future v3.31.0. While writing the beginning of that release's release note, I however noticed that the API wouldn't be complete without "play" and "pause" events, indicating respectively when the player exits a pause and when it enters it.

This PR adds those two events.

@peaBerberian peaBerberian added this to the 3.30.1 milestone May 29, 2023
@peaBerberian peaBerberian force-pushed the feat/playpauseevents branch 3 times, most recently from 8b36dff to 45f25cf Compare May 29, 2023 15:43
}
playPauseEventsCanceller = new TaskCanceller();
playPauseEventsCanceller.linkToSignal(currentContentCanceller.signal);
if (willAutoPlay !== !videoElement.paused) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could also be written willAutoPlay === videoElement.paused but I though it was less understandable and that the double negation was, for once, more readable

@peaBerberian peaBerberian force-pushed the feat/playpauseevents branch 2 times, most recently from 5a15abd to 79cb512 Compare June 13, 2023 16:16
@peaBerberian peaBerberian merged commit 45376d0 into next Jun 13, 2023
3 checks passed
@peaBerberian peaBerberian modified the milestones: 3.30.1, 3.31.0 Jun 13, 2023
@peaBerberian peaBerberian mentioned this pull request Jun 13, 2023
@peaBerberian peaBerberian deleted the feat/playpauseevents branch July 6, 2023 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant