How To Save Current Playing Song In Cookie?
I am using jPlayer plugin. Here is an example link [ jsfiddle ]. I save the current playing track number in a cookie. After a browser reload it starts playing from the track numbe
Solution 1:
myPlayer.play()
expects an integer
value, but when you read from the cookie you get a string
. So to fix your problem, just pass the value through parseInt()
, like this:
myPlayer.play(parseInt(playnow));
You will notice that on page reload, the proper track will be selected in the playlist as it starts playing, and it will continue to the next track correctly.
Demo: http://jsfiddle.net/alan0xd7/6kx616hr/1/
By the way, I think setInterval
with 1
(1 millisecond) is too much, maybe 1000
(1 second) is enough.
Post a Comment for "How To Save Current Playing Song In Cookie?"