Skip to content

Stop calling pause() before play promise resolved#68

Open
otacke wants to merge 3 commits intoh5p:masterfrom
otacke:fix-pause-before-play-resolved
Open

Stop calling pause() before play promise resolved#68
otacke wants to merge 3 commits intoh5p:masterfrom
otacke:fix-pause-before-play-resolved

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