Control start position and duration of play in HTML5 video

Custom start position and duration of play in HTML5 video

// Set video element to variable
var video = document.getElementById('player1');

var videoStartTime = 0;
var durationTime = 0;

video.addEventListener('loadedmetadata', function () {
    videoStartTime = 20;
    durationTime = 40;
    this.currentTime = videoStartTime;
}, false);

//  paused and playing events to control buttons
video.addEventListener("pause", function () {
   alert('pause');
}, false);

video.addEventListener("playing", function () {
    alert('playing');
}, false);

Full Page Demo

Control start position and duration of play in HTML5 video Control start position and duration of play in HTML5 video Reviewed by Bhaumik Patel on 7:50 PM Rating: 5