Fixes togglePlay() unhandled exception in promise #31
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Brief
Fixes the new autoplay restrictions where Play() can fail due to Chrome/Safari not registering a user interaction before the video plays (with sound).
Summary
Suppose a video is in an html, which will call video.play to auto-start the video. This video.html is embedded as a same-host iframe. If the user has been using the app then no problem the video autoplays fine.
HOWEVER
If this user takes this link and sends it to one of their friends the video autoplay will fail. In this scenario, chrome/firefox/safaria etc will actually block the video play because the user hasn't click anything yet. The clue that this has happened is that the browser invoke an exception to the promise of video.play(). However, moovie doesn't handle this because the promise is not returned to the caller.
The solution is to change togglePlay() such that the promise is returned to the caller, where the error condition can be gracefully handled.
This enables an attempt at autoplay, with a fallback behavior such as displaying the play.svg button to cue the user to play click the play button. Infact this is exactly the solution I'm using.