Developer Guide Javascript API Reference Developer Tools Release Notes

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.

github

Click the button to reload the page with a time offset of 15 seconds. The appends #t=30 to the URL.

const hash = window.location.hash;
let offset = hash ? Number(window.location.hash.substr(3)) : false;
let shouldPlay = !!hash;

const playerInstance = jwplayer('player').setup({
  playlist: 'https://cdn.jwplayer.com/v2/media/1b02B03R',
  autostart: shouldPlay
});

playerInstance.on('firstFrame', () => {
  if (offset) {
    playerInstance.seek(offset);
  }
  offset = false;
});

document.getElementById('set-offset').addEventListener('click', () => {
  window.location.hash = '#t=15';
  window.location.reload();
});