Javascript – HTML5 video player prevent seeking

htmlhtml5-videojavascript

I'm creating a series of video tutorials and would like to prevent users from seeking forward and skipping sections. I'll be using an HTML5 video player that will be used for desktop and iPad browsers. Ideally, I'd like this to work on the iPhone as well, but I realize you have no control over the video on the phone since it uses the iPhone video player.

How can I prevent users from seeking forward on an HTML5 video player?

Best Answer

Another example for Video.js:

videojs('example_video_1').ready(function(){
  var player = this;
  var previousTime = 0;
  var currentTime = 0;
  var seekStart = null;

  player.on('timeupdate', function(){
    previousTime = currentTime;
    currentTime = player.currentTime();
  });

  player.on('seeking', function(){
    if(seekStart === null) {
      seekStart = previousTime;
    }
  });

  player.on('seeked', function() {
    if(currentTime > seekStart) {
      player.currentTime(seekStart);
    }
    seekStart = null;
  });
});