JS WMP Operation code Summary (music Lianbo function) _javascript skills

Source: Internet
Author: User
Tags string format
Common properties and methods in wmp-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 properties
wmp. url:string; Specify media location, native or network address
wmp.uiMode:String; Player interface mode, available for full, Mini, None, invisible
Wmp.playState:integer; Playback status, 1 = stop, 2 = pause, 3= playback, 6 = buffering, 9 = connecting, 10 = Ready
Wmp.enableContextMenu:Boolean; Enable/Disable right-click menu
Wmp.fullScreen:boolean; Whether to display full screen
Player common control
Wmp.controls.play; Play
Wmp.controls.pause; Time out
Wmp.controls.stop; Stop it
wmp.controls.currentPosition:double; Current progress
wmp.controls.currentPositionString:string; Current progress, string format. such as "00:23"
Wmp.controls.fastForward; Fast Forward
Wmp.controls.fastReverse; Get back!
Wmp.controls.next; Next song
wmp.controls.previous; A song.
Player common settings
Wmp.settings.volume:integer; Volume, 0-100
Wmp.settings.autoStart:Boolean; Whether to play automatically
Wmp.settings.mute:Boolean; Is Mute
Wmp.settings.playCount:integer; Number of plays
wmp.settings.balance =-100; (left sound)
wmp.settings.balance=100; (right voice)
wmp.settings.balance=0; (Panchong)
Common Current Media properties
wmp.currentMedia.duration:double; Total media length
wmp.currentMedia.durationString:string; Total media length, string format. such as "03:24"
Wmp.currentMedia.getItemInfo (const string); Get Current media information
"title" = Media title "Author" = artist "copyrights" = Copyright information
"Description" = Media content description "Duration" = Duration (seconds)
"FileSize" = File Size "FileType" = File type "sourceURL" = Original address
Wmp.currentMedia.setItemInfo (const string); Setting up media information by property name
wmp.currentMedia.name:string; Same Currentmedia.getiteminfo ("Title")
wmp.network.bufferingProgress; Buffer percent
wmp.network.downloadProgress; Download percent
More comprehensive page parameter settings
<object id= "Player" height= "width=" 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= "/>"
<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>
Related references and explanations see above!
<script language= "JavaScript" >
var Wmp=this.document.getelementbyid ("Player");
Play
function playthis (URL)
{
WMP. url = URL;
WMP.controls.play ();
}
</script>
How do I play a music list?
Train of thought: play a music list, you need to achieve two purposes, one is the loop, and the other is to determine whether the current song is finished. Loop only when the current song is finished playing. Implement instrumentation.
var i=0;
Playthis (Firstmusic)
Real-time detector with 1 seconds interval
D=setinterval (function Shwotimer ()
{
if (wmp.playstate==1)
{
if (i>=soundarray.length)
{
Empty the loop when all the playback is complete
Clearinterval (d);
}
Else
{
Play the next song when the playback is complete
Playthis (URL);
}
}
}
, 1000);
If you have other control needs, such as pausing, you can set an identity, that is, the current pause, the next step is playback, and vice versa
var pauseflag=0;
function Command_pause ()
{
if (pauseflag==0)
{
WMP.controls.Pause ();
}
Else
{
WMP.controls.play ();
}
Pauseflag=pauseflag==1?0: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.