这个程序,不能自动播放下一个音乐,怎么解决,
高手们,救命啊<script>
var MusicList=new Array()
MusicList[0]="http://media.twango.com/m1/original/0105/eb9dffb66d3242889fb4d8f254c31750.wma"
MusicList[1]="http://media.twango.com/m1/original/0105/9f1b4d82b5b24a439b85d0fb5a01e8e1.wma"
MusicList[2]="http://media.twango.com/m1/original/0105/8d58bd3d43f94047b7d8bdea73ac09c7.wma"
MusicList[3]="http://media.twango.com/m1/original/0105/512718f7a258464887970ccc3b50de59.wma"function loadPlay()
{
try{
//document.WMP.URL=MusicList.options[0].value;
document.WMP.URL=MusicList[0];//指定(播放)列表中的第一首歌曲
document.WMP.controls.play(); //播放
}catch(e){} //try{}catch(e){}表示忽略程序运行中出现的错误
}
function getMusicIndex()
{
try{
var MusicIndex=0; //存储当前播放歌曲的位置 for(i=0;i<MusicList.length;i++)
{
if(document.WMP.URL==MusicList[i])
//if(document.WMP.URL==MusicList.options[i])
{
MusicIndex=i; //记录下当前播放歌曲的位置
break;
}
}
return MusicIndex; //整个函数返回当前播放歌曲的下标位置
}catch(e){}
setTimeout('getMusicIndex()',1000); //每隔1秒就检测一下当前播放歌曲的位置
}
getMusicIndex(); //调用getMusicIndex()函数function playPrevious()
{
try{
var PlayIndex=getMusicIndex(); //将当前播放歌曲的位置存储到PlayIndex变量中
PlayIndex--; //当前播放歌曲的位置-1就表示起上一曲的位置
//document.WMP.URL=MusicList.options[PlayIndex];
document.WMP.URL=MusicList[PlayIndex];
document.WMP.controls.play();
}catch(e){}
}
function playNext()
{
try{
var PlayIndex=getMusicIndex(); //将当前播放歌曲的位置存储到PlayIndex变量中
PlayIndex++; //当前播放歌曲的位置+1就表示起下一曲的位置
//document.WMP.URL=MusicList.options[PlayIndex];
document.WMP.URL=MusicList[PlayIndex];
document.WMP.controls.play();
}catch(e){}
}
function control(me)
{
switch (me)
{
case 1 : //暂停
document.WMP.controls.pause();
break;
case 2 : //播放
document.WMP.controls.play();
break;
case 0 : //停止
document.WMP.controls.stop();
break;
}
}
</script>
<object id="WMP" classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" width="0" height="0" loop=-1>
<param name="URL">
<param name="uiMode" value="none"><!-- none,mini,full -->
<param name="enableContextMenu" value="false">
</object>
<br>
<button onclick="control(2)">播放</button>
<button onclick="control(1)">暂停</button>
<button onclick="control(0)">停止</button>
<button onclick="playPrevious()">上一曲</button>
<button onclick="playNext()">下一曲</button>
<button onclick="window.close()">关闭窗口</button>
</BODY>
</head>
</html>
高手们,救命啊<script>
var MusicList=new Array()
MusicList[0]="http://media.twango.com/m1/original/0105/eb9dffb66d3242889fb4d8f254c31750.wma"
MusicList[1]="http://media.twango.com/m1/original/0105/9f1b4d82b5b24a439b85d0fb5a01e8e1.wma"
MusicList[2]="http://media.twango.com/m1/original/0105/8d58bd3d43f94047b7d8bdea73ac09c7.wma"
MusicList[3]="http://media.twango.com/m1/original/0105/512718f7a258464887970ccc3b50de59.wma"function loadPlay()
{
try{
//document.WMP.URL=MusicList.options[0].value;
document.WMP.URL=MusicList[0];//指定(播放)列表中的第一首歌曲
document.WMP.controls.play(); //播放
}catch(e){} //try{}catch(e){}表示忽略程序运行中出现的错误
}
function getMusicIndex()
{
try{
var MusicIndex=0; //存储当前播放歌曲的位置 for(i=0;i<MusicList.length;i++)
{
if(document.WMP.URL==MusicList[i])
//if(document.WMP.URL==MusicList.options[i])
{
MusicIndex=i; //记录下当前播放歌曲的位置
break;
}
}
return MusicIndex; //整个函数返回当前播放歌曲的下标位置
}catch(e){}
setTimeout('getMusicIndex()',1000); //每隔1秒就检测一下当前播放歌曲的位置
}
getMusicIndex(); //调用getMusicIndex()函数function playPrevious()
{
try{
var PlayIndex=getMusicIndex(); //将当前播放歌曲的位置存储到PlayIndex变量中
PlayIndex--; //当前播放歌曲的位置-1就表示起上一曲的位置
//document.WMP.URL=MusicList.options[PlayIndex];
document.WMP.URL=MusicList[PlayIndex];
document.WMP.controls.play();
}catch(e){}
}
function playNext()
{
try{
var PlayIndex=getMusicIndex(); //将当前播放歌曲的位置存储到PlayIndex变量中
PlayIndex++; //当前播放歌曲的位置+1就表示起下一曲的位置
//document.WMP.URL=MusicList.options[PlayIndex];
document.WMP.URL=MusicList[PlayIndex];
document.WMP.controls.play();
}catch(e){}
}
function control(me)
{
switch (me)
{
case 1 : //暂停
document.WMP.controls.pause();
break;
case 2 : //播放
document.WMP.controls.play();
break;
case 0 : //停止
document.WMP.controls.stop();
break;
}
}
</script>
<object id="WMP" classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" width="0" height="0" loop=-1>
<param name="URL">
<param name="uiMode" value="none"><!-- none,mini,full -->
<param name="enableContextMenu" value="false">
</object>
<br>
<button onclick="control(2)">播放</button>
<button onclick="control(1)">暂停</button>
<button onclick="control(0)">停止</button>
<button onclick="playPrevious()">上一曲</button>
<button onclick="playNext()">下一曲</button>
<button onclick="window.close()">关闭窗口</button>
</BODY>
</head>
</html>
return "function" == typeof o ? (window.onload = o) : document.getElementById(o) || o
}
$.addEvent = function(object, event, methood) {
object == window ? object[event] = methood :
object.addEventListener ? object.addEventListener(event, methood, !!0) :
object.attachEvent(event, function(){methood.apply(object, arguments)});
}
$.clssPlay = function(Containe, Musicarr) {
this.Index = 0;
this.Musicarr = Musicarr;
this.Containe = Containe;
this.Starplay = function() {
var url = this.Musicarr[this.Index];
with ($(this.Containe)) {
hasChildNodes() && removeChild(firstChild);
innerHTML = [
"<embed type='application/x-ms-wmp' src='"+ url +"' width='0' height='0'>",
"<object classid='CLSID:6bf52a52-394a-11d3-b153-00c04f79faa6' width='0' height='0'>\
<param name='url' value='"+ url +"'></object>"
][! + "\v1" + 0];
}
this.Listener();
}
this.Controls = function(o) {
with ($(this.Containe)["firstChild"]["controls"]) {
eval(["play()", "pause()", "stop()"][o]);
}
}
this.PrevNext = function(o) {
var lens = this.Musicarr.length;
this.Index = o ? ++ this.Index % lens : this.Index > 0 ? -- this.Index : lens - 1;
this.Starplay();
}
this.Listener = function() {
var This = this, obj = $(This.Containe)["firstChild"];
$.addEvent(!+"\v1"?obj:window, !+"\v1"?"PlayStateChange":"OnDSPlayStateChangeEvt", function(o){
o != "8" || setTimeout(function(){This.PrevNext(1)}, 2000);
})
}
}
$(function(){
var Musicarr = [
"http://media.twango.com/m1/original/0105/eb9dffb66d3242889fb4d8f254c31750.wma",
"http://media.twango.com/m1/original/0105/9f1b4d82b5b24a439b85d0fb5a01e8e1.wma",
"http://media.twango.com/m1/original/0105/8d58bd3d43f94047b7d8bdea73ac09c7.wma",
"http://media.twango.com/m1/original/0105/512718f7a258464887970ccc3b50de59.wma"
];
this.player = new $.clssPlay("showplayer", Musicarr);
this.player.Starplay();
})</script><div id="showplayer"></div>
<button onclick="player.Controls(0)">播 放</button>
<button onclick="player.Controls(1)">暂 停</button>
<button onclick="player.Controls(2)">停 止</button>
<button onclick="player.PrevNext(0)">上一曲</button>
<button onclick="player.PrevNext(1)">下一曲</button>
<button onclick="window.close()">关闭窗口</button>
return "function" == typeof o ? (window.onload = o) : document.getElementById(o) || o
}
$.addEvent = function(object, event, methood) {
object == window ? object[event] = methood :
object.addEventListener ? object.addEventListener(event, methood, !!0) :
object.attachEvent(event, function(){methood.apply(object, arguments)});
return this
}
$.clssPlay = function(Containe, Musicarr, Options) {
this.Index = 0;
this.Musicarr = Musicarr;
this.Containe = Containe;
for (var options in Options||{}) {
this[options] = Options[options];
}
this.Starplay = function() {
var url = this.Musicarr[this.Index];
with ($(this.Containe)) {
hasChildNodes() && removeChild(firstChild);
innerHTML = [
"<embed type='application/x-ms-wmp' src='"+ url +"' width='430' height='65'>",
"<object classid='CLSID:6bf52a52-394a-11d3-b153-00c04f79faa6' width='430' height='65'>\
<param name='url' value='"+ url +"'></object>"
][! + "\v1" + 0];
}
this.Listener();
}
this.Controls = function(o) {
with ($(this.Containe)["firstChild"]["controls"]) {
eval(["play()", "pause()", "stop()"][o]);
}
}
this.PrevNext = function(o) {
this.Controls(2);
var lens = this.Musicarr.length;
this.Index = o ? ++ this.Index % lens : this.Index > 0 ? -- this.Index : lens - 1;
this.Starplay();
}
this.Listener = function() {
var This = this, obj = $(This.Containe)["firstChild"];
$.addEvent(!+"\v1"?obj:window, !+"\v1"?"PlayStateChange":"OnDSPlayStateChangeEvt", function(o){
o != "8" || setTimeout(function(){This.PrevNext(1)}, 2000);
}).addEvent(obj, "error", function(){
setTimeout(function(){This.PrevNext(1)}, 2000);
})
}
}
$(function(){
var Musicarr = [
"http://zt.wzdsb.net/special/wzdjy/1.mp3",
"http://file.qlteacher.com/upload/gz2010/medias/1007/29/095808787.mp3",
"http://www.xiyufeng.com/bbs/attachment/fid_16/16_2879_6ef4917aadae04e.mp3",
"http://www.yvonee.com/wp-content/media/ch/yehui.mp3"
];
this.player = new $.clssPlay("showplayer", Musicarr, {});
this.player.Starplay();
})</script><div id="showplayer"></div>
<button onclick="player.Controls(0)">播 放</button>
<button onclick="player.Controls(1)">暂 停</button>
<button onclick="player.Controls(2)">停 止</button>
<button onclick="player.PrevNext(0)">上一曲</button>
<button onclick="player.PrevNext(1)">下一曲</button>
<button onclick="window.close()">关闭窗口</button>
<style type="text/css">
*{margin:0;padding:0}
#theExample{position:absolute;left:400px;top:50px}
#Vcontainer{position:relative;left:0px;top:0px;width:368px;height:30px;background:#eee}
#Vdragerimg{position:absolute;left:0px;top:0px;cursor:pointer;width:30px;height:30px}
#Lcontainer{position:relative;left:0px;top:31px;width:368px;height:30px;background:#eee}
#Ldragerimg{position:absolute;left:0px;top:0px;cursor:pointer;width:30px;height:30px}
#showStatus{width:368px;height:19px;border:1px solid #000;font-size:10pt;line-height:19px;overflow:hidden;text-align:center}
</style><script type="text/javascript">
function $(o) {
return "function" == typeof o ? (window.onload = o) : document.getElementById(o) || o
}
$.domClss = function (o){
return o.currentStyle || document.defaultView.getComputedStyle(o, null);
}
$.addEvent = function(object, event, method) {
object == window ? object[event] = method :
object.addEventListener ? object.addEventListener(event, method, !!0) :
object.attachEvent(event, function(){method.apply(object, arguments)});
return this
}
$.dragMove = function (container, drager, callback, Initialize) {
var X = container.offsetWidth - drager.offsetWidth;
var Y = container.offsetHeight - drager.offsetHeight;
typeof Initialize == 'function' && Initialize(container, drager, X, Y);
drager.onmousedown = function (e) {
var _x = _y = m = n = 0, e = e || window.event;
e.preventDefault ? e.preventDefault() : (e.returnValue = false);
m = e.clientX - parseInt($.domClss(drager).left) + 2;
n = e.clientY - parseInt($.domClss(drager).top ) + 2;
document.onmousemove = function (e) {
var e = e || window.event,
x = e.clientX-m,y = e.clientY-n,
kx = X >= 0 && x <= X && x >= 0,
ky = Y >= 0 && y <= Y && y >= 0;
! kx || (drager.style.left = x +'px', _x = 100 *x/X >> 0);
! ky || (drager.style.top = y +'px', _y = 100 *y/Y >> 0);
typeof callback == 'function' && callback(_x, _y);
return false
}
document.onmouseup = function () {
document.onmouseup = document.onmousemove = null;
}
}
return this
}$.clssPlay = function(Containe, Musicarr, options) {
this.Index = 0;
this.Valum = 20;
this.Musicarr = Musicarr;
this.Containe = Containe;
for (var option in options) {
this[option] = options[option]
}
this.Starplay = function() {
var url = this.Musicarr[this.Index];
with ($(this.Containe)) {
hasChildNodes() && removeChild(firstChild);
innerHTML = [
"<embed id='MPL' type='application/x-ms-wmp' src='"+ url +"' width='368' height='300'>",
"<object id='MPL' classid='CLSID:6bf52a52-394a-11d3-b153-00c04f79faa6' width='368' height='300'>\
<param name='url' value='"+ url +"'></object>"
][! + "\v1" + 0];
}
this.Listener();
this.dControl();
}
this.bControl = function(o) {
with ($("MPL")["controls"]) {
eval(["play()", "pause()", "stop()"][o]);
}
}
this.PrevNext = function(o) {
this.Controls(2);
var lens = this.Musicarr.length;
this.Index = o ? ++ this.Index % lens : this.Index > 0 ? -- this.Index : lens - 1;
this.Starplay();
}
this.Listener = function() {
var This = this;
$.addEvent(!+"\v1"?$("MPL"):window, !+"\v1"?"PlayStateChange":"OnDSPlayStateChangeEvt", function(o) {
o != "8" || setTimeout(function(){This.PrevNext(1)}, 2000);
}).addEvent($("MPL"), "error", function(o) {
setTimeout(function(){This.PrevNext(1)}, 2000);
})
}
this.dControl = function() {
var This = this;
$.dragMove(this.Vcontainer, this.Vdragerimg, function(x, y) {
This.Valum = $("MPL").settings.volume = x;
}, function(c, d, x, y) {
d.style.left = x * This.Valum / 100 + "px";
$("MPL").settings.volume = This.Valum;
}).dragMove(this.Lcontainer,this.Ldragerimg, function(x, y) {
$("MPL").controls.currentPosition = $("MPL").currentMedia.duration * x / 100;
}, function(c, d, x, y) {
typeof Time == "undefined" || clearInterval(Time);
var Time = setInterval(function() {
d.style.left = x * $("MPL").controls.currentPosition / $("MPL").currentMedia.duration || 0+"px";
$(This.showStatus).innerHTML = $("MPL").status.replace(/“.*”/g, "") + " " +
$("MPL").controls.currentPositionString + "/" + $("MPL").currentMedia.durationString || "";
}, 1000);
})
}
}$(function(){
var Musicarr = [
"http://zt.wzdsb.net/special/wzdjy/1.mp3",
"http://file.qlteacher.com/upload/gz2010/medias/1007/29/095808787.mp3",
"http://www.xiyufeng.com/bbs/attachment/fid_16/16_2879_6ef4917aadae04e.mp3",
"http://www.yvonee.com/wp-content/media/ch/yehui.mp3"
];
var player = new $.clssPlay("showplayer", Musicarr, {
Vcontainer : $("Vcontainer"),
Vdragerimg : $("Vdragerimg"),
Lcontainer : $("Lcontainer"),
Ldragerimg : $("Ldragerimg"),
showStatus : $("showStatus")
});
var Button = document.getElementsByTagName("button");
for (var i = 0; Button[i]; i ++) {
with ({i : i}) {
$.addEvent(Button[i], !+"\v1"?"onclick":"click", function() {
i > 4 ? window.close() : i > 2 ? player.PrevNext(eval(i - 3)) : player.bControl(i);
})
}
}
player.Starplay();
})</script><div id="theExample">
<div id="showplayer"></div>
<button>播 放</button>
<button>暂 停</button>
<button>停 止</button>
<button>上一曲</button>
<button>下一曲</button>
<button>关闭窗口</button>
<div id="showStatus"></div>
<div id="Vcontainer"><img id="Vdragerimg" src="http://avatar.profile.csdn.net/0/8/4/2_guest.jpg" title="音量大小"><div>
<div id="Lcontainer"><img id="Ldragerimg" src="http://avatar.profile.csdn.net/0/8/4/2_guest.jpg" title="播放进度"><div>
</div>
this.PrevNext = function(o) {
this.Controls(2);
var lens = this.Musicarr.length;
this.Index = o ? ++ this.Index % lens : this.Index > 0 ? -- this.Index : lens - 1;
this.Starplay();
}
中的“this.Controls(2);”改为“this.bControl(2);”