Linking to a Time Offset

In this demo the video starts from the beginning by default. However, if there is a time offset hash in the URL, the video will start from that time.

License: All
Player Version:
Author: JW Player | GitHub
This demo includes:
  • on('ready')
  • on('firstFrame')

<script type="text/javascript">

var timeIntervalUrl = window.location.href + '#t=30';
var playerContainer = document.querySelector('.timeContainer');

function forceRefresh(){
  location.reload();
}

playerContainer.innerHTML = '<a href="' + timeIntervalUrl + '" onclick="forceRefresh()">Click here</a> to reload the page with a time offset of 30 seconds. The link simply appends #t=30 to the URL.'

var offset;
var shouldPlay;


if(window.location.hash) {
     offset = window.location.hash.substr(3);
     shouldPlay = true;
}

jwplayer().on('ready', function(event){
 if(shouldPlay === true){
   jwplayer().play();
 }
});

jwplayer().on('firstFrame', function() { 
jwplayer().seek(offset)
});
</script>
Please Note: This player implementation is a Proof of Concept only provided to show the possibilities of the JW Player and Platform and should not be taken as an offer to create, edit or maintain custom integration or development.