vendredi 17 avril 2015

HTML5 audio, testing if playing with javascript

Alright so I have audio on my site, and I want a user to only be able to play one audio at a time, regardless of how many tabs or windows the user has open. So if the user starts a new song in a different tab, the other one stops playing. Quick disclaimer: I have it working right now, but it's not a good method. Right now I have it so that when the user starts an audio file, it creates a php session with a random id for the instance of the playback. Then if a song is playing, it constantly sends ajax to the server to see if the session id is the same as the song's playback id. if the id is not the same, the playback stops. So right now it's working 100% how I want it, but it's sending so many requests to the server so I know there has to be a better way with using cookies or something. Please help if you can.


Aucun commentaire:

Enregistrer un commentaire