Js wmp operation code Summary (music connection function)

Source: Internet
Author: User

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? ;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.