Skip to content

Instantly share code, notes, and snippets.

@MaxPower15
Created April 17, 2012 19:13
Show Gist options
  • Save MaxPower15/2408358 to your computer and use it in GitHub Desktop.
Save MaxPower15/2408358 to your computer and use it in GitHub Desktop.
Untested method to get percentWatched
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;
});
@sbws
Copy link

sbws commented Jun 21, 2012

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();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment