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

Stop calling pause() before play promise resolved #68

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

otacke
Copy link
Contributor

@otacke otacke commented Mar 14, 2022

Currently, the HTML5 handler calls video.pause() directly after calling video.play(), e.g. when switching from one quality version to another. This can result in a DOMException, because the play promise needs to be resolved first (please cmp. Google's developer guidelines).

When merged in, this will be fixed by applying the pattern suggested in Google's developer guidelines and keep the current behavior as fallback for browsers that do not support promises.

scripts/html5.js Outdated
})
.catch(function (error) {
video.pause(); // Fallback
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as the above comment:
playPromise.finally(() => video.pause());

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@fnoks Makes total sense! Done.

@otacke otacke force-pushed the fix-pause-before-play-resolved branch from d782b2c to 856263e Compare March 2, 2023 12:09
@otacke otacke force-pushed the fix-pause-before-play-resolved branch from 856263e to fdc00db Compare March 2, 2023 12:19
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.

2 participants