Created
January 21, 2015 14:39
-
-
Save julzmon/cfc8b5a6fed80175129e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<script> | |
var videoElement = document.getElementById("videoElement"); | |
document.addEventListener("visibilitychange", function() { | |
if (document.hidden) { | |
$("#videoElement").animate({volume: 0}, 1000, "linear", function() { | |
videoElement.pause(); | |
}); | |
} else { | |
videoElement.play(); | |
$("#videoElement").animate({volume: 1}, 1000, "linear"); | |
} | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment