File indexing completed on 2024-12-15 04:23:43

0001 //var player, timer, timeSpent = [], display = document.getElementById('display');
0002 
0003 //function onYouTubeIframeAPIReady() {
0004 //    player = new YT.Player( 'player', {
0005 //        events: { 'onStateChange': onPlayerStateChange }
0006 //    });
0007 //}
0008 
0009 //function onPlayerStateChange(event) {
0010 //    if(event.data === 1) { // Started playing
0011 //        if(!timeSpent.length){
0012 //            timeSpent = new Array( parseInt(player.getDuration()) );
0013 //        }
0014 //        timer = setInterval(record,100);
0015 //    } else {
0016 //        clearInterval(timer);
0017 //    }
0018 //}
0019 
0020 //function record(){
0021 //    timeSpent[ parseInt(player.getCurrentTime()) ] = true;
0022 //    showPercentage();
0023 //}
0024 
0025 //function showPercentage(){
0026 //    var percent = 0;
0027 //    for(var i=0, l=timeSpent.length; i<l; i++){
0028 //        if(timeSpent[i]) percent++;
0029 //    }
0030 //    percent = Math.round(percent / timeSpent.length * 100);
0031 //    console.log(percent + "%");
0032 //}