Skip to content

Commit

Permalink
enabling basic support for analyzing watch time
Browse files Browse the repository at this point in the history
  • Loading branch information
efonsecab committed Apr 11, 2024
1 parent dc10af0 commit baf1668
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/FairPlayCombinedSln/FairPlayTube/wwwroot/scripts/videojs.js
Original file line number Diff line number Diff line change
@@ -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);
}

0 comments on commit baf1668

Please sign in to comment.