javascript写的一个MidiaPlayer的类
运行时候根据需求,改动这里即可
mpl.OpenUrl("DuskToDawn.wma");
下面是完整代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>MediaPlayer示例</title>
<mce:style type="text/css"><!--
body
{
font-size:12px;
font-family:宋体;
}
#divMpl
{
height: 137px;
width: 277px;
}
#divMsg
{
height: 155px;
overflow:auto;
width: 376px;
}
--></mce:style><style type="text/css" mce_bogus="1"> body
{
font-size:12px;
font-family:宋体;
}
#divMpl
{
height: 137px;
width: 277px;
}
#divMsg
{
height: 155px;
overflow:auto;
width: 376px;
}
</style>
<mce:script language="javascript" type="text/javascript"><!--
/* MediaPlayer类定义 冰点原创 */
function MediaPlayer()
{
this.dom=null;
}
MediaPlayer.uiMode=
{
Full:"full",
Mini:"mini",
None:"none",
Invisible:"invisible"
}
MediaPlayer.prototype={
CreateAt:function(id) //在指定ID的标签中创建MediaPlayer控件,大小由该标签决定
{
this.dom=document.createElement("object");
this.dom.classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6";
this.dom.style.width="100%";
this.dom.style.height="100%";
var container=document.getElementById(id);
container.innerHTML="";
container.appendChild(this.dom);
this._Init();
},
BindID:function(id) //绑定一个已存在的Object标签,该标签应该为一个MediaPlayer控件
{
this.dom=document.getElementById(id);
this._Init();
},
_Init:function() //初始化,注册事件
{
var _this=this;
this.dom.attachEvent("PlayStateChange",
function(newState){_this.onPlayStateChange(newState)});
this.dom.attachEvent("Buffering",function(bStart){ _this.onBuffering(bStart) });
this.dom.attachEvent("Error",function(){ _this.onError(); });
this.dom.attachEvent("PositionChange",
function(oldPos,newPos){ _this.onPositionChange(oldPos,newPos); } );
this.dom.attachEvent("StatusChange",function(){ _this.onStatusChange(); })
},
onPlayStateChange:function(newState)
{
switch(newState)
{
case 1: //wmppsStopped
this.onStop();
break;
case 2: //wmppsPaused
this.onPaused();
break;
case 3: //wmppsPlaying
this.onPlay();
break;
case 4: //wmppsScanForward
break;
case 5: //wmppsScanReverse
break;
case 6: //wmppsBuffering
th
补充:web前端 , JavaScript ,