Click here to Skip to main content
15,889,877 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I would like to display a video (.mp4) file while splash screen is being loaded in c#. I tried following i was able to get the audio to play however the video is not displayed on the screen. Not sure if i need to add anything else to display the video.

What I have tried:

private void SplashScreen_Load(object sender, EventArgs e)
       {

           timer1.Start();
           PlayFile(@"D:\Logo.mp4");


       }

       //Trying to add video.

       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 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();
       }
Posted
Updated 2-Apr-17 6:42am

1 solution

You have not place a control on the form to make the video visible, the media play only exists within the scope of the PlayFile method.

This article might help you along: Audio and Video Player C# Winform[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900