问题
I have the following html5 document with audio tag and a fallback to Flash for browsers that don't support it:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
</head>
<body>
<audio autoplay controls preload="auto" autobuffer>
<source src="trumpet.ogg" type="audio/ogg">
<source src="trumpet.mp3" type="audio/mp3">
<source src="trumpet.wav" type="audio/wav">
<source src="trumpet.m4a" type="audio/aac">
<!-- Flash fallback -->
<object width="1" height="1" type="application/x-shockwave-flash" data="player.swf">
<param name="movie" value="player.swf">
<param name="flashvars" value="file=trumpet.mp3">
</object>
</audio>
</body>
</html>
All of the files are returned by the service with the correct MIME type in the http header. The solution works fine for all browsers that except Internet Explorer 9 and 10 (except for compatibility mode because there the Flash file will play).
In those two browsers I can see the player controls with an error message that reads "Error: Unsupported audio type or invalid file path". I tried to shuffle around the order of the source tags, but couldn't find a solution to get it to play any of them.
Does anyone have a hint what to check or what it going wrong here?
Please see http://l.urff.at/html5audioexample for the above markup in action.
Thanks in advance for any helpful tips or hints! :)
回答1:
Your example works fine for me in IE10 on Windows 8.
You should be aware that:
- you should only need Ogg Vorbis and AAC (.m4a) to cover all browsers. The .wav and .mp3 won't help.
- some formats have complicated sub-formats, like .wav files can contain MP3 audio, .m4a files can contain certain sample rates or bit depths that a particular system might not support, and .ogg files could contain video or other content. Most browsers don't support all sub-formats, so you should carefully check the exact sub-formats of every sound you use and make sure they're supported. 16-bit 44.1KHz mono/stereo is almost always supported, so try not to deviate from that.
来源:https://stackoverflow.com/questions/13312488/error-unsupported-audio-type-or-invalid-file-path-for-html5-audio-tag-in-inte