Right-click Toolbox, select items (I) ... display "Select toolbox items", COM components, Windows Media Player wmp.dll add
[Basic Properties] url:string; Specify the media location, native or network address uimode:string; Player interface mode, available for full, Mini, None, Invisible (no case) Playstate:integer; Playback status. This property changes when both the Playstatechange event and the StateChange event are raised. The value range is enumerated: Wmplib.wmpplaystate, its members are as follows: wmppsundefined = 0; Unknown state wmppsstopped = 1; Playback stop wmppspaused = 2; Play Pause wmppsplaying = 3; Playing wmppsscanforward = 4; Search forward wmppsscanreverse = 5; Search Backwards wmppsbuffering = 6; Buffering wmppswaiting = 7; Waiting for stream to start wmppsmediaended = 8; Playback stream has ended wmppstransitioning = 9; Prepare a new media file Wmppsready = 10; Ready to play wmppsreconnecting = 11; Attempt to reconnect streaming media data Wmppslast = 12; The last state, the state has not changed the write code in Playstatechange can prevent the issue of non-default types such as playing rmvb (with Wmppsready). Enablecontextmenu:boolean; Enable/Disable right-click menu Fullscreen:boolean; Whether full screen display//Player basic Control ctlcontrols.play; Play Ctlcontrols.pause; Suspension of Ctlcontrols.stop; Stop Ctlcontrols.currentPosition:double; Current Progress Ctlcontrols.currentPositionString:string; Current progress, string format. such as "00:23" Ctlcontrols.fastforward; Fast forward ctlcontrols.fastreverse; FastRetreat Ctlcontrols.next; Next song Ctlcontrols.previous; Previous [Settings] Wmp.settings//player basic Settings Settings.volume:integer; volume, 0-100 settings.autoStart:Boolean; Whether to play Settings.mute:Boolean automatically; Whether Mute settings.playCount:integer; Played//Sequential play Wmp.settings.setMode ("Shuffle", False)//Random play Wmp.settings.setMode ("Shuffle", True)//Loop play wmp.settings. SetMode ("Loop", True) [Currentmedia] Wmp.currentmedia//Current media properties currentMedia.duration:double; Total media length currentMedia.durationString:string; Media total length, string format. such as "03:24" Currentmedia.getiteminfo (const string); Get 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 Currentmedia.setiteminfo (const string); Set media information currentMedia.name:string by property name; With Currentmedia.getiteminfo ("Title")
Basic Setup Examples:
Axwindowsmediaplayer1.windowlessvideo = false; When set to False, double-click the screen to full screen Axwindowsmediaplayer1.fullscreen = true; Set player Full screen playback Axwindowsmediaplayer1.url = @ "mms://192.168.0.102/vod/jingwei.wma";// Play Resource AxWindowsMediaPlayer1.Ctlcontrols.play (); Play AxWindowsMediaPlayer1.Ctlcontrols.stop (); Stop AxWindowsMediaPlayer1.Ctlcontrols.pause (); Pause AxWindowsMediaPlayer1.settings.autoStart = true; AutoPlay AxWindowsMediaPlayer1.settings.mute = false; Mute axWindowsMediaPlayer1.settings.volume = +; Volume int 0 ~ 100 is the maximum volume axWindowsMediaPlayer1.currentMedia.duration.ToString ();// Film length axWindowsMediaPlayer1.Ctlcontrols.currentPosition = 30; Current playback position doubleaxWindowsMediaPlayer1.currentMedia.getItemInfo ("Title");// Title AxWindowsMediaPlayer1.currentMedia.getItemInfo ("Author");//author
Full Screen control Instance code:
Using system.io;using wmplib; Public Videoplay () {InitializeComponent (); Full screen settings and hide mouse this. WindowState = formwindowstate.maximized; This. FormBorderStyle = Formborderstyle.none; Cursor.hide (); Player Full Screen Rectangle screensize = system.windows.forms.systeminformation.virtualscreen;//Gets the width and height of the screen. Panel1. Location = new System.Drawing.Point (0, 0); This.panel1.Size = new System.Drawing.Size (screensize.width,screensize.height); This.axWindowsMediaPlayer1.Location = new System.Drawing.Point (0, 0); This.axWindowsMediaPlayer1.Size = new System.Drawing.Size (screensize.width, screensize.height); Player Settings Axwindowsmediaplayer1.uimode = "None";//Player Style Axwindowsmediaplayer1.stretchtofit = true;//non-full When the screen state is stretched to the optimal size Axwindowsmediaplayer1.enablecontextmenu = false;//Disable the player right-click menu} private IWMPP Laylist videolist;//Creating playlists private bool IfLoop = true;//Video Looping//setting whether to loop the public bool IfLoop {get {return if Loop; } set {IfLoop = value;} }//The private void Axwindowsmediaplayer1_statuschange (object sender, EventArgs e) Occurs when the playback state is changed { Determine if the video has stopped playing if ((int) axwindowsmediaplayer1.playstate = = 1) {//Pause for 2 seconds and replay again System.Threading.Thread.Sleep (2000); Re-play//axwindowsmediaplayer1.ctlcontrols.play (); }}//Play public void Videostart () {axWindowsMediaPlayer1.Ctlcontrols.play (); }//List play public void Videoliststart () {videoplaylist ();//Retrieve playlist Axwindows MediaPlayer1.Ctlcontrols.play (); }//Pause public void Videopause () {axWindowsMediaPlayer1.Ctlcontrols.pause (); }//Replay public void VideorePlay () {videostop (); Videostart (); }//List replay public void Videolistreplay () {axwindowsmediaplayer1.currentplaylist = Videolist ;//Reload playlist videostart (); }//Stop playing public void Videostop () {//axwindowsmediaplayer1.currentplaylist.cl Ear ();//Clear List axWindowsMediaPlayer1.Ctlcontrols.stop (); }//Video mute public void Videomute (bool t) {AxWindowsMediaPlayer1.settings.mute = t; }//Play the next video public void Videonext () {///determine if the currently played video is the last if of the list (Axwindowsmedia Player1.currentMedia.name = = axwindowsmediaplayer1.currentplaylist.item[ Axwindowsmediaplayer1.currentplaylist.count-1].name) {} else { AxWindowsMediaPlayer1.Ctlcontrols.next ();//Play Next}}//Play previous media public void Videopreviou S () {//Determines whether the currently played video is the first if of the list (AxWindowsMediaPlayer1.currentMedia.name = = Axwindowsmediaplayer1.currentplaylis T.item[0].name) {} else {AXWINDOWSMEDIAPLAYER1.CTLCONTROLS.PR Evious ();//Play Last}}//Get playback Class table and initialize public void Videoplaylist () {Videoli st = AxWindowsMediaPlayer1.playlistCollection.newPlaylist ("one");//Create playlist string path = @ ". \data\video";//media path DirectoryInfo dir = new DirectoryInfo (path); foreach (FileSystemInfo fsi in dir. Getfilesysteminfos ()) {if (FSI is FileInfo) {FileInfo fi = ( FileInfo) FSI; Videolist.appenditem (Axwindowsmediaplayer1.newmedia (FI. FullName)); }} axwindowsmediaplayer1.currentplaylist = videolist;//Find the video, play the class table AxWindowsMediaPlayer1. Settings.setmode ("Loop", ifloop);//Set class table loop playback}
Introduction to Common methods of C # player controls