This solution seems a bit hacky, but if the Safari browser browser does not throw an event when the video is stopped, there are many options left -
To detect if a video has stopped, we can first make sure that the script knows when the video is playing, therefore:
var isPlaying1 = false, isPlaying2 = false, // if more videos an array is better to use, or reuse lastTime1 = 0, lastTime2 = 0; // etc. $('video1').on('playing', function() { isPlaying1 = true; }); $('video1').on('ended', function() { isPlaying1 = false; });
This sets the play flag when starting the video. Use the ended event to set it to false if it was played back to the end or was stopped manually.
The next step is to poll the current video playback time to see if it changes. If no changes are specified, the video does not play (and does not get into the event to be completed):
function check() { if (isPlaying1) { var video = $('video1')[0]; if (video.currentTime === lastTime1) {
The scan rate should not exceed 30 frames per second. This is due to the fact that the time stamp will not be changed from what would correspond to the time from one frame to another. To be safe, use half the speed, as in the example for the most famous frame rate (videos rarely exceed 30 frames per second in the United States or 25 frames per second in Europe). If you know that videos will be played at a lower rate, the lowest rate should be here. It can also be reduced to reduce the overall load.
To stop checking, just call:
clearInterval(timerID); // timerID is in global scope
You may encounter a race condition between the completed event and the validation (as both create asynchronous behavior). If that matters, it depends on how you deal with two situations.
As said, it feels like a “hacker”, it hasn’t been tested on my part (only theorized, because I can’t configure the entire test environment for it), but I hope this helps you bypass this Safari limitation of the mobile browser.