Last active
January 29, 2016 18:59
-
-
Save Telematica/7389a5acc523e0f5e2fb to your computer and use it in GitHub Desktop.
JS Misc Stuff
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 defaults = { | |
'MDBykpSXsSE' : { min : 423, max : 430, current : 425 } | |
,'MDBykpSXsSE' : { min : 423, max : 430, current : 425 } | |
} | |
,video = document | |
.querySelector('video') | |
.addEventListener( | |
'timeupdate' | |
,function(e) | |
{ | |
//Todo: match 'v' parameter vs videoIds | |
//location.search.replace('?','').split('&').forEach(function(a,b,c){console.log(values = a.split('=')); params[values[0]]=values[1]; }); | |
if(e.target.currentTime > 430 || e.target.currentTime <= 424 ) | |
{ | |
e.target.currentTime=425; | |
} | |
} | |
); | |
//Page Visibility API | |
//https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API | |
document.addEventListener( | |
'visibilitychange' | |
,function() | |
{ | |
if(document.hidden) | |
{ | |
video.pause(); | |
return; | |
} | |
video.play(); | |
} | |
,false | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment