Announcing our brand new Developer Guides and API documentation in beta! Click here to see the new docs.

Resuming Playback

The startOnSeek ad rule allows publishers to determine whether or not viewers should be shown pre-rolls when seeking on subsequent visits.

License: Enterprise
Player Version:
Author: Alex Bussey | GitHub
This demo includes:
  • on('time')
The viewer's position will be saved in the browser's local storage. When the viewer leaves the page and returns, the player will display the pre-roll and then seek to the viewer's last position.
<script type="text/javascript">

	const playerInstance = jwplayer('player');
	const startOnSeek = document.getElementById('startOnSeek');
	let startOnSeekValue = localStorage['jwplayer.startOnSeek'] || 'pre';
	let starttimeValue = Number(localStorage['jwplayer.starttime']) || 0;

	playerInstance.setup({
		playlist: [{
			file: 'https://cdn.jwplayer.com/manifests/HoBIqXuR.m3u8',
			image: 'https://cdn.jwplayer.com/thumbs/HoBIqXuR.jpg',
			starttime: starttimeValue
		}],
		advertising: {
			client: 'vast',
			tag: 'assets/preroll.xml',
			rules: {
				startOnSeek: startOnSeekValue
			}
		}
	}).on('time', function(evt) {
		localStorage['jwplayer.starttime'] = evt.position;
	});

	startOnSeek.addEventListener('change', function(e) {
		e.preventDefault();
		localStorage['jwplayer.startOnSeek'] = startOnSeek.value;
	});

</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.