Created
September 11, 2012 21:20
-
-
Save MaxPower15/3702165 to your computer and use it in GitHub Desktop.
Code to preserve time and play/pause state when switching tabs
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 lastT = 0; | |
var downT = 0; | |
var lastState = "unknown"; | |
wistiaEmbed.bind("timechange", function(t) { | |
lastT = t; | |
}); | |
wistiaEmbed.bind("down", function() { | |
downT = lastT; | |
}); | |
wistiaEmbed.bind("up", function() { | |
if (downT > 0) { | |
wistiaEmbed.time(downT); | |
if (lastState === "playing") { | |
wistiaEmbed.play(); | |
} else { | |
wistiaEmbed.pause(); | |
} | |
} | |
}); | |
// this line is pseudo-code | |
$("#my_tab").beforeLoseFocus(function() { | |
lastState = wistiaEmbed.state(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment