Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

html - HTML5 audio what audio formats are supported

I have short sound that I wish to play in my webapp using HTML5. I save it in 3 formats. wav, mp3 and ogg

I created 3 tags to play in different formats.

<audio controls autobuffer>
<source src="random_d5c589b1.wav" type="audio/x-wav">
</audio>

<audio controls autobuffer>
<source src="random_d5c589b1.ogg" type="application/ogg">
</audio>

<audio controls autobuffer>
<source src="random_d5c589b1.mp3" type="audio/mpeg">
</audio>

IE9 shows that it can play mp3 and it plays

FF5 shows that it can play wav, ogg. I do not hear it.

Chrome 12 is able to play all 3 formats but I do not hear anything.

When I use different audio files I can hear them in FF and Chrome. But I can't hear those I need.

Here is example:- http://kvartira-n.com/test-site/sound2.html


Thanks to Juhana. The problem was that I had only 2 channel speakers and 5+1 was selected in Windows. It is not clear to me why but some audio 2 channel files were hearable and other wasn't.

Thanks everyone problem is resolved now.

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

It's browser-specific. e.g. The .ogg file works in chrome and firefox but doesn't work in safari.

It's a good idea to provide alternate audio files. Here is the example by MDN web docs.

<audio controls>
  <source src="random_d5c589b1.wav" type="audio/x-wav">
  <source src="random_d5c589b1.ogg" type="application/ogg">
  <source src="random_d5c589b1.mp3" type="audio/mpeg">
</audio>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...