Summary
In the project there is a need to cycle through a video on a propaganda machine, and when the user clicks the left mouse button to launch full screen, can let the user experience the other functions of the computer.
Solution Solutions
Considering all Windows systems, the Windows Media Player COM component is used as a video player with a Windows-brought player.
However, in order to better meet the needs, the following playback control panel needs to be hidden, how to do it? Finally find a solution to set player properties
" None ";
Loop through the code, here for the player to add playlists, the code is as follows:
string[] filepaths = Directory.GetFiles (_videodirpath). Where (x = X.endswith (". mp4") || X.endswith (". wmv")). ToArray (); //Add a looping playlist foreach(varIteminchfilepaths) {WindowsMediaPlay.currentPlaylist.appendItem (Windowsmediaplay.newmedia (item)); } //No more taskbar display This. ShowInTaskbar =false; This. FormClosing + =videofrm_formclosing; Windowsmediaplay.clickevent+=windowsmediaplay_clickevent; Windowsmediaplay.keyupevent+=windowsmediaplay_keyupevent; Windowsmediaplay.statuschange+=Windowsmediaplay_statuschange; Windowsmediaplay.errorevent+=windowsmediaplay_errorevent; Windowsmediaplay.doubleclickevent+=windowsmediaplay_doubleclickevent; WindowsMediaPlay.Ctlcontrols.play ();
So, how to minimize the program when the user clicks it?
Attention
In the case of Uimode = "None", clicking the event that will trigger the video pause does not exit. Video paused, is not the video status changed? So when we intercept the Click Video event, we can intercept it when the video is paused. The StateChange event corresponds to the following method:
voidWindowsmediaplay_statuschange (Objectsender, EventArgs e) { /** 0 Undefined Windows Media Player is a Undefined state. (undefined) 1 Stopped Playback of the current media item is Stopped. (stop) 2 Paused Playback of the current media item is Paused. When a media item is paused, resuming
Playback begins from the same location. (stay) 3 Playing The current media item is Playing. (played) 4 Scanforward the current media item is fast forwarding. 5 Scanreverse The current media item is fast rewinding. 6 buffering The current media item was getting additional data from the server. (conversion) 7 waiting Connection is established, and the server is not sending data. Waiting for session to begin. (pause) 8 mediaended Media item has completed playback. (end of playback) 9 transitioning Preparing New media item. Ten ready to begin playing. (ready) reconnecting reconnecting to stream. (reconnect)*/ Try { Switch(windowsmediaplay.playstate) { CaseWMPLib.WMPPlayState.wmppsBuffering: Break; CaseWMPLib.WMPPlayState.wmppsLast: Break; CaseWMPLib.WMPPlayState.wmppsMediaEnded: Break; CaseWMPLib.WMPPlayState.wmppsPaused://Click the video to exitHidevideo (); Break; CaseWMPLib.WMPPlayState.wmppsPlaying:if(!windowsmediaplay.fullscreen) {Windowsmediaplay.fullscreen=true; } Break; CaseWMPLib.WMPPlayState.wmppsReady: Break; CaseWMPLib.WMPPlayState.wmppsReconnecting: Break; CaseWMPLib.WMPPlayState.wmppsScanForward: Break; CaseWMPLib.WMPPlayState.wmppsScanReverse: Break; CaseWMPLib.WMPPlayState.wmppsStopped: Break; CaseWMPLib.WMPPlayState.wmppsTransitioning: Break; CaseWMPLib.WMPPlayState.wmppsUndefined: Break; CaseWMPLib.WMPPlayState.wmppsWaiting: Break; default: Break; } } Catch(Exception ex) {Loginfodata.writelog (NewLoginfo {Dt=DateTime.Now, Issend=false, Message=Ex. Message, Op="Media_state_change_err" }); } }
The logic of double-clicking on full-screen interception can also be handled here, double-clicking will definitely have a single click, so here you can double-click to maximize the processing.
[Winform] Media player Playback Control Panel control, click event Intercept