I am trying to figure this out, hoping someone can shed some light.
I am trying to get a song to play continuously throughout a site.
I didnt want to use frames.
It works fine 9 times out of 10. However (in IE surprise surprise). Every now and then, it fails, the debugger throws the error: Error: DOM Exception: INDEX_SIZE_ERR (1)
Here is the code I am using:
startPos = sessionStorage.getItem('playbackPosition');
document.getElementById('bgTrack').currentTime = startPos;
window.addEventListener("unload", recordTime, false);
An old-fashioned hack you could try is to have the site hidden within a frameset with a hidden frame where your audio plays. This isn't a very good solution.
A better method is to use a cookie (on unload) to store the current audio position by communicating with the player, then setting it when the player starts on page load if the cookie exists, otherwise starting from the beginning.
Either method described above could be tweaked to allow it to be opt-in or opt-out.
Ok I tried flooring the value, as well as rounding it to a specific number of decimal places, without success.
the error appears to be completely random and confined to IE. I cannot replicate the problem in any other browser.
It may well just be a bug. So I think what i'm going to do is attempt to set the currentTime to the value of the sessionStorage variable. However on the odd occasion that it fails, set the currentTime to 0 so that the track simply plays from the beginning:
i am stuggling witht the same issue, but my solution is to never reload the page. i use hash navigatino and ajax to show pages instead of the normal hyperlinks. this is actually very easy if you have consistent html containers in your templates. all you need to do is re-write in-site links to perform an ajax load and dump of the href onclick...
you can poke the href to location.hash so that the url works as expected.
I was grateful for that script!
I can't get the music to play in Firefox - it works fine in Safari.
(I don't think it's the script - I think it's the format. I am using the html5 audio and supplying an .ogg.)
Also is there a way to customize the skin of the media player ?