Skip to content

Instantly share code, notes, and snippets.

@joe-watkins
Last active August 29, 2015 14:16
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 joe-watkins/6b65f01b6cdeae8c4731 to your computer and use it in GitHub Desktop.
Save joe-watkins/6b65f01b6cdeae8c4731 to your computer and use it in GitHub Desktop.
Test to see if HTML5 Video is buffered.
/*
Tests to see if video has been buffered.
html5VideoBufferedTest(player,showVideo);
https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement
*/
var html5VideoBufferedTest = function(videoObject,callback_function){
videoBuffered = false;
setInterval(function(){
if(videoObject.readyState == 4){ // VIDEO IS BUFFERED
// assign global
videoBuffered = true;
// if callback run it
if(callback_function){ callback_function(); }
clearInterval(html5VideoBufferedTest);
}
},400);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment