Skip to content

Instantly share code, notes, and snippets.

@robwalch
Last active August 29, 2015 14:06
Show Gist options
  • Save robwalch/35b1737a3b34e5223a27 to your computer and use it in GitHub Desktop.
Save robwalch/35b1737a3b34e5223a27 to your computer and use it in GitHub Desktop.
JW Player event delegation example
var jw = jwplayer('jwplayer').setup({file:"videofile.mp4"});
var noop = function() {/* do nothing */}
var timeDelegate = noop;
jw.onTime(timeDelegate);
jw.onPlaylistItem(function(itemEvent) {
if (itemEvent.index === 1) {
timeDelegate = function(timeEvent) {
/* do something here for the second video in the playlist */
console.log('time', timeEvent, 'item', itemEvent);
}
} else {
/* go back to doing nothing */
timeDelegate = noop;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment