playerInstance.on('complete', (event) => { console.log('Vod play completed'); jwplayer("myElement").load({ file: 'https://bscmaf.akamaized.net/hls/live/218166/testbs/master.m3u8', }); console.log('Live url loaded'); playerInstance.play(); console.log('Live url started'); playerInstance.on('play', function() { // Now that the player is ready, we can check the stream type console.log('Live player ready again'); liveCheckInterval = setInterval(function() { if (playerInstance.getState() !== 'idle' && playerInstance.getConfig().streamType === 'LIVE') { console.log(playerInstance.getState()); console.log(playerInstance.getConfig().streamType); console.log('A live stream is currently back playing.'); // Start playing the newly loaded LIVE content immediately } else { console.log('still no live back'); console.log(playerInstance.getState()); console.log(playerInstance.getConfig().streamType); console.log('A live stream is not currently playing. V2'); switchToVOD(); } }, 15000); // check every 15 seconds })}