Simulating Live TV

A demo that simulates live TV. The playlist item and position are determined by system date/time.

License: All
Player Version:
Author: JW Player | GitHub
This demo includes:
  • on('ready')
  • play()
  • seek()
  • playlistItem()
<script type="text/javascript">

var playerInstance = jwplayer("myElement");

// In order for this demo to work, duration must be included for each playlist item.

playerInstance.setup({
    "playlist": "//content.jwplatform.com/feeds/DrqpQIzP.rss"
});

playerInstance.on('displayClick', function() {
	playerInstance.pause();
});
    
playerInstance.on('ready', function() {
    var seconds = new Date().getMinutes()*60 + new Date().getSeconds();
    var playlist = playerInstance.getPlaylist();
    var offset = 0;

    for (var index=0; index < playlist.length; index++) {
        var duration = Math.round(playlist[index]['duration']);
        if(offset + duration > seconds) {
            playerInstance.playlistItem(index);
            playerInstance.seek(seconds-offset);
            break;
        } else {
            offset += duration;
        }
    }
});

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