[Winform] Media player Playback Control Panel control, click event Intercept

Source: Internet
Author: User

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

Related Article

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.