How to make so that after the video ends a new form opens?
- Well, in fact, yes. WinForm: As soon as the video ends - windows media player closes and a new form opens. Does wmp have any similar events? - Timothy
|
1 answer
If it suits you, try an example from here: https://msdn.microsoft.com/en-us/library/dd562692(v=vs.85).aspx The example shows how you can work with WindowsMediaPlayer using using WMPLib; If you do not find the library, try to find it along the path: \ windows \ system32 \ wmp.dll
Just in case the code is:
WMPLib.WindowsMediaPlayer Player; private void PlayFile(String url) { Player = new WMPLib.WindowsMediaPlayer(); Player.PlayStateChange += new WMPLib._WMPOCXEvents_PlayStateChangeEventHandler(Player_PlayStateChange); Player.MediaError += new WMPLib._WMPOCXEvents_MediaErrorEventHandler(Player_MediaError); Player.URL = url; Player.controls.play(); } private void Form1_Load(object sender, System.EventArgs e) { // TODO Insert a valid path in the line below. PlayFile(@"c:\myaudio.wma"); } private void Player_PlayStateChange(int NewState) { if ((WMPLib.WMPPlayState)NewState == WMPLib.WMPPlayState.wmppsStopped) { this.Close(); } } private void Player_MediaError(object pMediaObject) { MessageBox.Show("Cannot play media file."); this.Close(); } And inside Player_PlayStateChange specify which form in your application to load. If you need a form to be visible at the start of the application, but only to use the player, hide the starting form.
- And where will my video be played? do i need to add windowsmediaplayer? - Timofey
- Component to display? Yes. Add it to the form and it will display a video, for example. You can watch a video with an example: youtube.com/watch?v=xlIZQed46Jw - DarkOwl
|