在 html 中嵌入 mp3
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6807464/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Embed mp3 in html
提问by MTA
I used this code for embed a mp3 file to html:
我使用此代码将 mp3 文件嵌入到 html:
<EMBED SRC="mp3 link" HEIGHT=60 WIDTH=300>];
the problem is that the browser download the file and than he play it, there is any way for do it in buffer or something like this?
问题是浏览器下载文件然后播放它,有什么办法可以在缓冲区或类似的东西中做到这一点?
because i want the user will not wait.
因为我希望用户不会等待。
回答by Leopold Stotch
For browsers that support HTML 5 you can use this:
对于支持 HTML 5 的浏览器,您可以使用:
<audio src="song.mp3" controls="controls">
Your browser does not support the audio element.
</audio>
Otherwise you'd have to use JQuery as suggested above, or a flash audio player.
否则,您必须按照上面的建议使用 JQuery,或者使用 Flash 音频播放器。
回答by Emil Condrea
Google has a good player :
谷歌有一个很好的播放器:
<embed type="application/x-shockwave-flash" flashvars="audioUrl=MP3_FILE_URL" src="http://www.google.com/reader/ui/3523697345-audio-player.swf" width="400" height="27" quality="best"></embed>
回答by You
Use the audio
element of HTML5:
使用audio
HTML5的元素:
<audio src="[mp3 link]" preload controls></audio>