-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 now properly return Promises #1229
Conversation
Great idea! The media element play method returns a promise, the pause method is currently not standardised and therefore we cannot rely on it returning a promise. In general I think it is a good idea to return the play promise as you said. I think adjusting the JSdoc comments above the functions are still missing. (Maybe also with an Regarding the implementation for WebAudio the specs should be useful: AudioContext.resume and AudioBufferSourceNode.start |
That's fine if I can update the JSDoc blocks when I get some spare time again. |
Short description of changes:
This should fix errors such as "Uncaught (in promise) DOMException: The play() request was interrupted by a new load request", as developers can now use the returned Promise to wait for subsequent media actions.
Breaking in the external API:
N/A - though the documentation should be updated to let developers know that
play
,pause
, andplayPause
now return a Promise as per the HTML5 audio spec (this PR should also work for WebAudio API as well, but please verify!)Breaking changes in the internal API:
Not sure. Shouldn't be any.
Todos/Notes:
Might be a good idea to review WebAudio and HTMLAudio specs and check which methods return Promises, and return those from Wavesurfer's methods.
Related Issues and other PRs:
Issue #771 could be related.