WMP-common attributes and methods in Web pages
<Object classid = "CLSID: 6BF52A52-394A-11d3-B153-00C04F79FAA6" type = "application/x-oleobject" id = "wmp" width = "0" height = "0" style = "width: 0px; height: 0px; "> </object>
// Basic attributes
Wmp. URL: String; // specifies the media location, local address or network address
Wmp. uiMode: String; // player interface mode, which can be Full, Mini, None, Invisible
Wmp. playState: integer; // playback status, 1 = stopped, 2 = paused, 3 = playing, 6 = buffering, 9 = connecting, 10 = ready
Wmp. enableContextMenu: Boolean; // enable/disable the context menu
Wmp. fullScreen: boolean; // whether to display in full screen
// Player Common Control
Wmp. controls. play; // play
Wmp. controls. pause; // pause
Wmp. controls. stop; // stop
Wmp. controls. currentPosition: double; // current progress
Wmp. controls. currentPositionString: string; // current progress, string format. For example"
Wmp. controls. fastForward; // fast forward
Wmp. controls. fastReverse; // return quickly
Wmp. controls. next; // The next song
Wmp. controls. previous; // previous line
// Player common settings
Wmp. settings. volume: integer; // volume, 0-100
Wmp. settings. autoStart: Boolean; // whether to play automatically
Wmp. settings. mute: Boolean; // whether to mute
Wmp. settings. playCount: integer; // Number of playbacks
Wmp. settings. balance =-100; // (left)
Wmp. settings. balance = 100; // (right)
Wmp. settings. balance = 0; // (full voice)
// Common current media attributes
Wmp. currentMedia. duration: double; // total media Length
Wmp. currentMedia. durationString: string; // total media length, in string format. For example"
Wmp. currentMedia. getItemInfo (const string); // obtain the current media information
// "Title" = media Title "Author" = artist "Copyright" = Copyright information
// "Description" = media content Description "Duration" = Duration (seconds)
// "FileSize" = file size "FileType" = file type "sourceURL" = original address
Wmp. currentMedia. setItemInfo (const string); // set media information by attribute name
Wmp. currentMedia. name: string; // same as currentMedia. getItemInfo ("Title ")
Wmp. network. bufferingProgress; // buffer percentage
Wmp. network. downloadProgress; // download percentage
Comprehensive page parameter settings
<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>
For references and explanations, see the preceding section!
<Script language = "javascript">
Var wmp1_this.doc ument. getElementById ("Player ");
// Play
Function playthis (url)
{
WMP. URL = url;
WMP. controls. play ();
}
</Script>
How to play a music list?
Idea: To play a music list, you need to implement two purposes: one is loop, and the other is to determine whether the current song is played completely. The loop is performed only after the current song is played completely. This achieves detection.
Var I = 0;
Playthis (firstmusic)
// Real-time detector, with an interval of 1 second
D = setInterval (function shwotimer ()
{
If (WMP. playState = 1)
{
If (I> = SoundArray. length)
{
// Clear the loop after the playback is complete.
ClearInterval (d );
}
Else
{
// When the playback is complete, play the next one.
Playthis (url );
}
}
}
, 1000 );
If you need other controls, such as pause, you can set an identifier, that is, the current pause, the next step is playing, and vice versa.
Var pauseflag = 0;
Function Command_Pause ()
{
If (pauseflag = 0)
{
WMP. controls. Pause ();
}
Else
{
WMP. controls. play ();
}
Pauseflag = 1? ;
}