Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

html - "Error: Unsupported audio type or invalid file path" for HTML5 Audio tag in Internet Explorer 10

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! :)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...