videojs / videojs-contrib-ads

A Tool for Building Video.js Ad Plugins
http://videojs.github.io/videojs-contrib-ads/
Other
384 stars 257 forks source link

fix: content restarts from the beginning when snapshot restores source after midroll in iOS #290

Closed alex-barstow closed 6 years ago

alex-barstow commented 7 years ago

Problem

When the snapshot restores the content source following ad playback, the currentTime is not able to be set in iOS, causing the content to restart from the beginning following midrolls. Even with preload="auto", Safari loads only the video metadata, so we do not get a contentcanplay player event and setting the currentTime fails to seek the content.

Possible, albeit hacky solution

player.load() does not seem to make the content seekable in iOS. We still only get a contentloadedmetadata event, and setting the currentTime still fails. So far, the only way I have been able to override Safari's default preloading behavior is to add autoplay to the video element before changing the source. This way, we do get a contentcanplay event and the content is seekable by the time we try to update the currentTime. autoplay is then removed after the content starts playing.

Note:

This feels far from the ideal solution, but so far it's the only way I've been able to force Safari to load the content enough that we can seek. I am hoping others might have some better ideas (paging @incompl and @gkatsev). At the very least I wanted to start a conversation about how best to address this problem.

incompl commented 7 years ago

Is this problem introduced in a recent version of iOS? If not, what caused this problem to appear only recently?

alex-barstow commented 6 years ago

Updated the rollup version to 0.50 because an apparent issue in 0.41.6 was causing the Travis build to fail

mrocajr commented 6 years ago

QA Passed. No regressions found.