I also recently ran into this problem - it could be a race condition between play() and pause() . There seems to be a link to this problem, or something related here .
As @Patrick points out , pause does not return a promise (or anything else), so the solution above will not work. Although there are no pause() documents in MDN, the WC3 project for Media Elements says:
media.pause ()
Sets the paused attribute to true, loading the media resource if necessary.
That way, you can also check the paused attribute in their timeout callback.
Based on this great SO answer , here you can check if the video is actually playing (or not), so you can safely run play () without error.
var isPlaying = video.currentTime > 0 && !video.paused && !video.ended && video.readyState > 2; if (!isPlaying) { video.play(); }
Otherwise, @Patrick's answer should work.
JohnnyCoder Apr 27 '16 at 18:37 2016-04-27 18:37
source share