Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<video id="vid" width="320" height="240" controls="controls">
   <source src="http://www.w3schools.com/html5/movie.mp4" type="video/mp4">
    <source src="http://www.w3schools.com/html5/movie.ogv" type="video/ogg">
  Your browser does not support the video tag.
</video><br/>
<button id="set">play and seek</button>
<div id="log"></div>
 
function log(s){
 $("#log").append("<div>"+s+"</div>");
}
function isSeekable(video, time) {
  if(video.seekable && video.seekable.length>0) { 
    for(var i=0, l=video.seekable.length; i<l; i++){
      if(time>video.seekable.start(i) && time<video.seekable.end(i)) 
        return true;
    }
  }
  return false;
}
function seek(video, time) {
  if(isSeekable(video, time)) {
    log("video is seekable");
    video.currentTime = time;
  }
  else {
    log("video not seekable - will retry.");
    setTimeout(function(){seek(video, time);}, 100);
  }
}
$(function(){
  $("#set").click(function(){
    var video = document.getElementsByTagName("video")[0];
    video.play();
    seek(video, 7);
  });
});
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers