I have a problem with part of my javascript code in IE9.
When I start the page I get an error: Unexpected call to method or property access.
This is my audio tag in html file:
<audio controls loop preload id="musicGame">
<source src="mp3/ambient.ogg" type="audio/ogg" />
<source src="mp3/ambient.mp3" type="audio/mpeg" />
</audio>
I'm calling my audio tag in javascript like that:
musicGame = $('#musicGame')[0];
Then I'm pausing it because I have a mute button and I need to pause all songs on my page in order for mute to work.
musicGame.pause();
This is where IE9 throws an error.
Any ideas what could be wrong?
oog
is not supported in IE .. mp3
however is supported in IE9+ ..
Try setting your preload
attribute since IE9 might have issues with the preload
attribute, so try and set it to preload="metadata"
<audio controls loop preload="metadata" id="musicGame">
<source src="mp3/ambient.ogg" type="audio/ogg" />
<source src="mp3/ambient.mp3" type="audio/mpeg" />
</audio>
Sometimes preload="auto"
might work, but you will have to test!?
You might have to specify your audio source in the audio
elements src
attribute instead, without a child source
element
<audio src="mp3/ambient.mp3" controls autoplay loop id="musicGame">
HTML5 audio not supported
</audio>
Also are using the right DOCTYPE
for HTML5?
<!DOCTYPE html>
And are using the right meta tag
for IE9 like this?
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
And instead of using $('#musicGame')[0]
have you also tried to just use?
document.getElementById("musicGame");
Some useful resource links:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With