如何在网页中嵌入 mp3 文件 [英] how to embed mp3 file in web page
问题描述
我有一套 mp3 文件,当页面被请求时需要随机选取一个文件并应该在我的网页中作为背景音乐播放是否有跨浏览器的方式(需要工作主要的网络浏览器,如 IE、firefox、chrome) 这样做?
I have set of mp3 files that when page is requested need to randomly pick up one file and should play as background music in my web page is there a cross browser way(need to work major web browsers such as IE,firefox,chrome) of doing this?
推荐答案
使用 JW Player http://www.longtailvideo.com/players/jw-flv-player/ 播放 MP3,但请不要在没有用户要求的情况下播放音乐.这将使用户对您网站的 GTFO 感兴趣.
Use JW Player http://www.longtailvideo.com/players/jw-flv-player/ to play MP3, but please don't play music without the user request. This will make the user to GTFO of your website.
示例:http://www.longtailvideo.com/support/jw-player-setup-wizard?example=202
<script type='text/javascript' src='swfobject.js'></script>
<div id='mediaspace'>This text will be replaced</div>
<script type='text/javascript'>
var so = new SWFObject('player.swf','mpl','470','24','9');
so.addParam('allowfullscreen','true');
so.addParam('allowscriptaccess','always');
so.addParam('wmode','opaque');
so.addVariable('duration','33');
so.addVariable('file','http://www.longtailvideo.com/jw/upload/bunny.mp3');
so.write('mediaspace');
</script>
这篇关于如何在网页中嵌入 mp3 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!