0

I'm making a music mixer, but when I switch to the other tabs in chrome, setInterval will stop calling a function.

I found this: How can I make setInterval also work when a tab is inactive in Chrome? but my problem is, I'm using setInterval for changing volume smoothly between songs and not for animation. So I can't use Date() method. I don't even want to use something like jQuery, just pure Javascript.

Actually, my JS code is not small so theres link to js code: http://warhome.eu/play/player.js

and the PHP file: http://pastebin.com/FWJDW7e0

Thanks for help!

Community
  • 1
  • 1
Marek Schubert
  • 107
  • 1
  • 2
  • 10
  • Did you see the [second answer to that question](http://stackoverflow.com/a/12522580/298053) that mentions audio fading? – Brad Christie Aug 24 '13 at 20:09

1 Answers1

0

So I solved it... Seems chrome supports setInterval even it is inactive, but it extends the interval. So solution is to use onblur and onfocus events to determine, if tab is inactive or not.

So final js code's here: http://warhome.eu/play/player_final.js

Marek Schubert
  • 107
  • 1
  • 2
  • 10