diff --git a/src/FairPlayCombinedSln/FairPlayTube/wwwroot/scripts/videojs.js b/src/FairPlayCombinedSln/FairPlayTube/wwwroot/scripts/videojs.js index 5e339558..9f1dfea8 100644 --- a/src/FairPlayCombinedSln/FairPlayTube/wwwroot/scripts/videojs.js +++ b/src/FairPlayCombinedSln/FairPlayTube/wwwroot/scripts/videojs.js @@ -1,3 +1,29 @@ +let timer = null; +let totalTime = 0; +let lastPlayerTime = null; +let player = null; function initializeVideoJsPlayer(playerElementId) { - videojs(playerElementId, {}); + debugger; + player = videojs(playerElementId, {}); + lastPlayerTime = player.currentTime(); + player.on('play', startPlaying); + player.on('pause', pausePlaying); +} + +function startPlaying() { + console.log('played'); + timer = window.setInterval(function () { + if (lastPlayerTime != player.currentTime()) { + totalTime += 1; + } + lastPlayerTime = player.currentTime(); + console.log(lastPlayerTime); + console.log(player.currentTime()); + console.log(totalTime); + }, 1000); +} + +function pausePlaying() { + console.log('stopped'); + if (timer) clearInterval(timer); } \ No newline at end of file