NO IMAGE

WMP-網頁中常見屬性和方法
<object classid=”CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6″ type=”application/x-oleobject” id=”wmp” width=”0″ height=”0″ style=”width:0px;height:0px;”></object>

//基本屬性 
wmp.URL:String; //指定媒體位置,本機或網路地址
wmp.uiMode:String; //播放器介面模式,可為Full, Mini, None, Invisible
wmp.playState:integer; //播放狀態,1=停止,2=暫停,3=播放,6=正在緩衝,9=正在連線,10=準備就緒
wmp.enableContextMenu:Boolean; //啟用/禁用右鍵選單
wmp.fullScreen:boolean; //是否全屏顯示

//播放器常用控制
wmp.controls.play; //播放
wmp.controls.pause; //暫停
wmp.controls.stop; //停止
wmp.controls.currentPosition:double; //當前進度
wmp.controls.currentPositionString:string; //當前進度,字串格式。如“00:23”
wmp.controls.fastForward; //快進
wmp.controls.fastReverse; //快退
wmp.controls.next; //下一曲
wmp.controls.previous; //上一曲

//播放器常用設定
wmp.settings.volume:integer; //音量,0-100
wmp.settings.autoStart:Boolean; //是否自動播放
wmp.settings.mute:Boolean; //是否靜音
wmp.settings.playCount:integer; //播放次數
wmp.settings.balance = -100; //(左聲)
wmp.settings.balance=100; //(右聲)
wmp.settings.balance=0; //(全聲)

//常用當前媒體屬性
wmp.currentMedia.duration:double; //媒體總長度
wmp.currentMedia.durationString:string; //媒體總長度,字串格式。如“03:24”
wmp.currentMedia.getItemInfo(const string); //獲取當前媒體資訊
//”Title”=媒體標題     “Author”=藝術家     “Copyright”=版權資訊
//”Description”=媒體內容描述     “Duration”=持續時間(秒)
//”FileSize”=檔案大小     “FileType”=檔案型別     “sourceURL”=原始地址
wmp.currentMedia.setItemInfo(const string); //通過屬性名設定媒體資訊
wmp.currentMedia.name:string; //同currentMedia.getItemInfo(“Title”)

wmp.network.bufferingProgress; //緩衝百分比
wmp.network.downloadProgress; //下載百分比
 
較全面的頁面引數設定
                <object id=”Player” height=”10″ width=”100″ classid=”CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6″>
                    <param name=”URL” value=”” />
                    <param name=”rate” value=”1″ />
                    <param name=”balance” value=”0″ />
                    <param name=”currentPosition” value=”0″ />
                    <param name=”defaultFrame” />
                    <param name=”playCount” value=”1″ />
                    <param name=”autoStart” value=”true” />
                    <param name=”currentMarker” value=”0″ />
                    <param name=”invokeURLs” value=”-1″ />
                    <param name=”baseURL” />
                    <param name=”volume” value=”50″ />
                    <param name=”mute” value=”0″ />
                    <param name=”uiMode” value=”invisible” />
                    <param name=”stretchToFit” value=”0″ />
                    <param name=”windowlessVideo” value=”0″ />
                    <param name=”enabled” value=”-1″ />
                    <param name=”enableContextMenu” value=”-1″ />
                    <param name=”fullScreen” value=”0″ />
                    <param name=”SAMIStyle” />
                    <param name=”SAMILang” />
                    <param name=”SAMIFilename” />
                    <param name=”captioningID” />
                    <param name=”enableErrorDialogs” value=”0″ />
                    <param name=”_cx” value=”6482″ />
                    <param name=”_cy” value=”6350″ />
                </object>

相關引用及解釋參見上面!

<script language=”javascript”>
    var WMP=this.document.getElementById(“Player”);
    //播放
    function playthis(url)
    {           
       WMP.URL = url;
       WMP.controls.play();
    }
</script>

如何播放一個音樂列表?
思路:播放一個音樂列表,需要實現兩個目的,一是迴圈,二是判斷是否當前歌曲播放完成.只有當前歌曲播放完成後才進行迴圈.實現檢測.

   var i=0;
   playthis(firstmusic)
   //實時檢測器,間隔時間為1秒
   d=setInterval(function shwotimer()
   {  
        if(WMP.playState==1) 
        { 
            if(i>=SoundArray.length)
            {       
                //當播放所有完成後清空迴圈                             
                clearInterval(d);
            }
            else
            {    
                 //當播放完成後播放下一首
                 playthis(url); 
            }
        }
  }
  ,1000);

如有其它控制需要,如暫停,可設定一個標識,即當前暫停,則下一步為播放,反之亦然
  var pauseflag=0;
  function Command_Pause()
  {
      if(pauseflag==0)
      {
          WMP.controls.Pause();
      }
      else
      {
          WMP.controls.play();                           
      }
      pauseflag=pauseflag==1?0:1;                  
  }