在网页中添加多首音乐循环播放代码

来源:互联网 发布:网络电影 开机 编辑:程序博客网 时间:2024/05/16 06:21

在网页中添加多首音乐循环播放代码

一、单曲播放(背景音乐为一首)
这类代码有:
1、<EMBED src="http://img.xiaonei.com/photos/20060603/1510/orig51097.wma" autostart="true" loop=infinite width=0 height=0>
<!-- 背景音乐-->
Volume表示音量,loop=infinite表示循环播放,不停止。这种代码是看不到播放器的。

2、<embed src="http://img.xiaonei.com/photos/20060603/1510/orig51097.wma"hidden=&q ... ;true"loop="true"><!-- 背景音乐-->
--------hidden="true"表示隐藏播放,即不显示播放器的外观,若要想显示,把"true" 替换为"false"即可,这样为默认是最小化播放,若还想具体显示播放器的大小,另加上height="高度值" width="宽度值" 就可以了。
-------autostart="true"表示当前页一载入则自动播放,若不希望播放改为autostart="false"
即可...
------ loop="true"表示无限次循环播放音乐直到当前页关闭为止,不想循环播放替换为 loop="false"就OK了

3、<embed src="http://img.xiaonei.com/photos/20060603/1510/orig51097.wma"autostart="true"loop=&q ... l"width="0"height="0"><!-- 背景音乐-->
---------loop="-1" 表示无限次循环播放,可设置播放次数,用具体数字代替即可,比如我希望它播放两次,则loop="2"
--------controls="ControlPanel"这个控制选项可省略
--------width="0" height="0"表示隐藏播放,和前面的一样。
若欲设置播放器的外观,则替换为具体的数值就可以了,比如width="123" height="100"

说明:上面的音乐网址都可自行修改,代码可以直接复制,建议将音乐上传到校内网上,这样加载速度快。

二、多首背景歌曲连播,有两种方法
1、使用M3u列表(只能播放Mp3格式的文件)
首先, 新建一个记事本文件(这个要是不会赶紧去学电脑...)
第二、从网上搜索你喜欢的歌曲,取得网址(一定要是Mp3格式的,其他格式不行),把你找来的MP3地址一个一行排好,一行只能排一个,不得有空行。如:
http://vip.hanzify.org/carlchina/temp/HITFMjh.mp3
http://vip.hanzify.org/carlchina/temp/HITFMjh.mp3
http://vip.hanzify.org/carlchina/temp/HITFMjh.mp3
就像这样,地址可以无限多,最少一个,然后保存,保存的文件名最好是英文或者数字。

然后将记事本文件的扩展名.txt改为.M3U,系统会提示改扩展名会导致文件可能不可用,是否继续?点“是”,文件变为M3U了。你也可以将txt文件另存为.M3U格式。接着你可以打开试听一下效果,如果地址够快的话在你电脑本地就可以进行听歌了。
最后,把这个M3U文件上传到校内网上,在上传好的文件里点属性,查看地址,将地址(一定是以M3u结尾的网址)贴进一下代码的音乐网址就可以了。
<EMBED src=音乐网址 width=180 height=50 type=audio/mpeg autostart="true" loop="true">
参数可以自己设置,请参照一自己修改。
2、使用ASX列表(不限制音乐格式)
首先新建一个记事本文件,将以下代码输入:
<ASX version ="3.0">
<Entry>
<Ref href = "http://img.xiaonei.com/photos/2006 ... 55328.wma"/>
</Entry>
<Entry>
<Ref href = "http://img.xiaonei.com/photos/2006 ... 46257.wma"/>
</Entry>
<Entry>
<Ref href = "http://img.xiaonei.com/photos/2006 ... 52716.wma"/>
</Entry>
<Entry>
<Ref href = "http://img.xiaonei.com/photos/2006 ... 55812.wma"/>
</Entry>
<Entry>
<Ref href = "http://img.xiaonei.com/photos/2006 ... 57023.wma"/>
</Entry>
<Entry>
<Ref href = "http://img.xiaonei.com/photos/2006 ... 57177.wma"/>
</Entry>
<Entry>
<Ref href = "http://img.xiaonei.com/photos/2006 ... 46257.wma"/>
</Entry>
<Entry>
<Ref href = "http://img.xiaonei.com/photos/2006 ... 58026.wma"/>
</Entry>
<Entry>
<Ref href = "http://img.xiaonei.com/photos/2006 ... 58502.wma"/>
</Entry>
</ASX>
然后另存为扩展名为.asx的文件,如music.asx。你可以打开一下试听。最后将此文件上传到校内网上,获取文件地址。
将下列代码加入涂鸦板即可:
<embed src="http://img.xiaonei.com/photos/20061121/1740/orig79888.asx"autostart="true"loop=&q ... l"width="0"height="0"><!-- 背景音乐-->
你也可以用上面介绍的方法自行设置参数。
这种方法,简单、高速、占资源少,且可以播放mp3,wma,asx等多种格式,且不必担心有弹出式广告之类。


说明:上面介绍的两种方法均需要先上传好音乐。

三、多首歌曲随机播放,只播放一首,但刷新一次,播放一首不相同的歌曲

新建一个记事本文件,将以下代码输入:
<head>
<SCRIPT language="javascript">
<!--

var sound1="http://img.xiaonei.com/photos/20061121/1640/orig46257.wma"

var sound2="http://img.xiaonei.com/photos/20061121/1710/orig71630.wma"

var sound3="http://img.xiaonei.com/photos/20061121/1720/orig55328.wma"

var sound4="http://img.xiaonei.com/photos/20061121/1720/orig55812.wma"

var sound5="http://img.xiaonei.com/photos/20061121/1730/orig57023.wma"

var sound6="http://img.xiaonei.com/photos/20061121/1730/orig57177.wma"

var sound7="http://img.xiaonei.com/photos/20061121/1640/orig46257.wma"

var sound8="http://img.xiaonei.com/photos/20061121/1730/orig58026.wma"

var sound9="http://img.xiaonei.com/photos/20061121/1740/orig58502.wma"

var sound10="http://img.xiaonei.com/photos/20061121/1720/orig55328.wma"

var x=Math.round(Math.random()*9)

if (x==0) x=sound1

else if (x==1) x=sound2

else if (x==2) x=sound3

else if (x==3) x=sound4

else if (x==4) x=sound5

else if (x==5) x=sound6

else if (x==6) x=sound7

else if (x==7) x=sound8

else if (x==8) x=sound9

else x=sound10

if (navigator.appName=="Microsoft Internet Explorer")

document.write('<bgsound src='+'"'+x+'"'+' loop="infinite">')

else

document.write('<embed src='+'"'+x+'"'+'hidden="true" border="0" width="20" height="20" autostart="true" loop="true">')


//-->
</SCRIPT>
</head>
修改方法:将里面的网址换成你的音乐地址

将记事本文件另存为htm网页文件,然后上传到校内网上,获取地址。
在涂鸦板中输入以下代码:
<div id=music><img src="javasc ript:music.innerHTML='<ifr ame src=http://img.xiaonei.com/photos/20061121/2020/orig92674.htm height=0 marginwidth=0 marginheight=0 hspace=0 vspace=0 fr ameborder=0 scrolling=no></ifr ame>'" style=display:none></div><!--背景音乐-->
中间的网址即是你上传的网页地址。
直接复制可能没用,请下载代码。见二楼附件。这种我觉得比较好,我目前用的就是这种。

原创粉丝点击