Created
April 17, 2012 19:13
-
-
Save MaxPower15/2408358 to your computer and use it in GitHub Desktop.
Untested method to get percentWatched
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var lastTime = 0, | |
watchedSecondHash = new Array(Math.floor(wistiaEmbed.duration())); | |
wistiaEmbed.bind("timechange", function(t) { | |
var totalSecondsWatched = 0, percentWatched; | |
watchedSecondHash[Math.floor(t)] = true; | |
for(var i=0; i < watchedSecondHash.length; i++) { | |
if (watchedSecondHash[i]) { | |
totalSecondsWatched++; | |
} | |
} | |
percentWatched = totalSecondsWatched / watchedSecondHash.length; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
slight change in calculating the pecentWatched... used duration instead of the hash length (was always the same as the total seconds watched):
percentWatched = totalSecondsWatched / wistiaEmbed.duration();