The main audio support audio formats:
mp3 ogg wav
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>audio</title> </head> <body> <!-- 方法一 --> <audio controls> <source src="data/imooc.mp3"></source> </audio> <!- Audio<->Method II controls src="data/imooc.mp3"></audio> </body> </html>
Level source did not write directly in the audio in high-src
About Compatibility:
mp3 compatible with all browsers
Ogg safari browser is not compatible with other available
wav compatible with all browsers
JS may be used to generate audio objects
< The Button the above mentioned id = "btn" > Play </ the Button > < Script > var myaudio = new new Audio (); myaudio.src = " the Data / imooc.mp3 " ; // Google and European friends can not be played directly must interact with the event // other browsers can btn.onclick = function () { myaudio.play (); } </ Script >
audio tag attributes
autoplay autoplay, Google and European friends can not play automatically (the difference is even and video mute settings will not autoplay)
<audio controls src="data/imooc.mp3" autoplay></audio>
No width and height attributes, needs to be controlled by the style
<audio controls src="data/imooc.mp3" autoplay width="500"></audio>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>audio</title> <style> audio{ width:500px; } </style> </head> <body> <audio controls src="data/imooc.mp3" autoplay></audio> </body> </html>