Developer Guide Javascript API Reference Developer Tools Release Notes

Resume Playback w/ Cookies

Use cookies to remember where the user left off and resume playback at the same time offset when revisiting the page.


const logger = new Logger('logger');

const playerInstance = jwplayer('player').setup({
  playlist: ''

playerInstance.once('play', function() {
  let cookieData = Cookies.get('resumevideodata');
  if (!cookieData) {
    return logger.log('No video resume cookie detected. Refresh page.');
  const [ resumeAt, duration ] = cookieData.split(':');

  if (resumeAt < duration) {;
    logger.log('Resuming at ' + resumeAt);

  logger.log('Video ended last time! Will skip resume behavior');

playerInstance.on('time', function(e) {
  Cookies.set('resumevideodata', `${Math.floor(e.position)}:${playerInstance.getDuration()}`);