📄 player.js
字号:
///////////////////////////////////////////////
// Author:daong | E-mail: dahongy@gmail.com
// Copyright © Http://stcms.vicp.net
// $Id: 09-03-23 final version $
///////////////////////////////////////////////
var Player = {
obj:{},
info:{},
thisId:0,
start:function(id,info,thisId){
this.obj = $$("MPlayer");
this.info = info;
this.thisId = thisId;
this.obj.PlayCount = 1000;
this.select(this.thisId);
this.play();
},
play:function(){
this.obj.controls.play();
},
stop:function(){
this.obj.controls.stop();
},
pause:function(){
this.obj.controls.pause();
},
open:function(url){
this.obj.URL=url;
},
list:function(){
html = "<table id=\"musicList\" width=\"100%\"><tr><td>名称</td><td>艺术家</td><td>试听</td><td>点击数</td></tr>";
for(i=0; i < this.info.length; i++)
{
if(i == this.thisId)
{
html = html + "<tr style='background-color:#e6f0ff' ondblclick=\"Player.select("+i+")\"><td>"+ this.info[i]['name'] +"</td><td>"+ this.info[i]['artist'] +"</td><td><button onclick=\"Player.select("+ i +");\">播放</button></td><td>"+ this.info[i]['hit'] +"</td></tr>";
}
else
{
html = html + "<tr ondblclick=\"Player.select("+i+")\"><td>"+ this.info[i]['name'] +"</td><td>"+ this.info[i]['artist'] +"</td><td><button onclick=\"Player.select("+ i +");\">播放</button></td><td>"+ this.info[i]['hit'] +"</td></tr>";
}
}
html = html + "</table>";
if($$("list")) $$("list").innerHTML=html;
},
select:function(i){
this.thisId = i; this.list(); this.obj.URL = this.info[i]['url']; this.play();
if(this.info[i]['lyric'])
LrcShow.start(this.info[i]['lyric'])
},
next:function(){
if(this.thisId < (this.info.length-1)){this.select(this.thisId+1)}else{this.select(0)}
},
pre:function(){
if(this.thisId > 0){this.select(this.thisId-1)}else{this.select(this.info.length-1)}
},
full:function(){
if(this.obj.playState == 3){this.obj.fullScreen = (this.obj.fullScreen ? 0 : 1);}else{showDialog("只有在播放状态下在可以全屏!");}
},
stateChange:function(num){
switch(num){
case 8:
setTimeout('Player.next()',100);
break;
}
},
error:function(){
showDialog("无法播放该文件,可能是链接已经失效!",'400','50',true,1000);
window.status = this.info[this.thisId]['name']+" 不能播放,正在跳至下一曲,请稍等2秒...";
if(this.info.length>1)
{
setTimeout("Player.next()",2000)
};
}
};
function play(id)
{
var musicInfo;
$.ajax({
url:"file.php?id="+id,
success:function(data){musicInfo = eval("("+data+")"); Player.start('MPlayer',musicInfo,0); Player.list();}
});
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -