日期:2014-05-16 浏览次数:20393 次
<!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> <style type="text/css"> body { font-size:12px; font-family:宋体; } #divMpl { height: 137px; width: 277px; } #divMsg { height: 155px; overflow:auto; width: 376px; } </style> <script language="javascript" type="text/javascript"> /* MediaPlayer类定义 */ function MediaPlayer() { this.dom=null; } MediaPlayer.uiMode= { Full:"full", Mini:"mini", None:"none", Invisible:"invisible" } MediaPlayer.prototype={ //在指定ID的标签中创建MediaPlayer控件,大小由该标签决定 CreateAt:function(id) { 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(); }, //绑定一个已存在的Object标签,该标签应该为一个MediaPlayer控件 BindID:function(id) { this.dom=document.getElementById(id); this._Init(); }, _Init:function() //初始化,注册事件 { var _this=this; if(!window.attachEvent) { this.dom.attachEvent=function(evn,fun) { } } 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 this.onBuffering_SC(); break; case 7: //wmppsWaiting break; case 8: //wmppsMediaEnded this.onMediaEnded(); break; case 9: //wmppsTransitioning this.onTransitioning(); break; case 10: //wmppsReady break; case 11: //w