如何使用启动画面显示视频 [英] How to display video with your splash screen

查看:72
本文介绍了如何使用启动画面显示视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在c#中加载启动画面时显示视频(.mp4)文件。我试过跟随我能够播放音频,但视频没有显示在屏幕上。不确定我是否需要添加任何其他内容来显示视频。



我尝试了什么:



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();
       }

推荐答案

您没有在表单上放置控件以使视频可见,媒体play只存在于 PlayFile 方法的范围内。



本文可能会帮助你:音频和视频播放器C#Winform [ ^ ]
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[^]


这篇关于如何使用启动画面显示视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆