Skip to content

Instantly share code, notes, and snippets.

@simoncozens
Created August 15, 2013 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simoncozens/6241066 to your computer and use it in GitHub Desktop.
Save simoncozens/6241066 to your computer and use it in GitHub Desktop.
$("#videoContainer").empty();
$("#videoContainer").append('<video id="video" webkit-playsinline=1 poster preload="metadata"><source id="source" type="video/mp4" src="'+Vibi.localCatalogue[book].video+'"/></video>');
var vid = $("#video")[0];
var f = function(e) {
vid.currentTime = startingTime;
};
vid.addEventListener("loadedmetadata", f);
// This hack is required to force iOS to buffer the video. Without it, it won't play. :(
// c.f. http://blog.millermedeiros.com/html5-video-issues-on-the-ipad-and-how-to-solve-them/
if (isIOS) {
if(vid.readyState !== 4){
setTimeout(function(){
vid.pause();
// And let's automatically play it.
Vibi.playVideo();
}, 1);
}
} else {
setTimeout(f, 1);
vid.play();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment