Created
April 2, 2018 16:19
-
-
Save rao123dk/9bc6af068a9b8d2de473259cb5e62097 to your computer and use it in GitHub Desktop.
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
//@@ I don’t want to listen to your music when I switch tabs | |
var track = new Audio('./darkhast.mp3'); | |
function isVisible (e){ | |
document.title = document.hidden ? 'please come back and enjoy your music' : 'Enjoying!'; | |
return document.hidden ? track.pause() : track.play(); | |
} | |
document.addEventListener('visibilitychange',isVisible); | |
//For more please :- | |
// https://www.html5rocks.com/en/tutorials/pagevisibility/intro/ | |
//https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment