码迷,mamicode.com
首页 > Windows程序 > 详细

[Winform]Media Player组件全屏播放的设置

时间:2017-06-20 16:28:05      阅读:307      评论:0      收藏:0      [点我收藏+]

标签:dia   png   logs   define   运行时   pre   ssi   事件   运行   

摘要

在设置程序开始运行时,让视频全屏播放时,直接设置

windowsMediaPlay.fullScreen = true;

会报错,代码如下

                windowsMediaPlay.URL = _videoPath;
                windowsMediaPlay.Ctlcontrols.play();
                windowsMediaPlay.fullScreen = true;
                windowsMediaPlay.ClickEvent += windowsMediaPlay_ClickEvent;
                windowsMediaPlay.KeyUpEvent += windowsMediaPlay_KeyUpEvent;
                windowsMediaPlay.StatusChange += windowsMediaPlay_StatusChange;

错误

技术分享

抱着相信微软的心情,就在猜想,可能是位置不对,是不是必须视频在播放中才可以设置全屏?

所以在视频状态变化的事件中,这样设置

        void windowsMediaPlay_StatusChange(object sender, EventArgs e)
        {
            /*  
             * 0 Undefined Windows Media Player is in an undefined state.(未定义) 
               1 Stopped Playback of the current media item is stopped.(停止) 
               2 Paused Playback of the current media item is paused. When a media item is paused, resuming 
playback begins from the same location.(停留) 3 Playing The current media item is playing.(播放) 4 ScanForward The current media item is fast forwarding. 5 ScanReverse The current media item is fast rewinding. 6 Buffering The current media item is getting additional data from the server.(转换) 7 Waiting Connection is established, but the server is not sending data. Waiting for session to begin.(暂停) 8 MediaEnded Media item has completed playback. (播放结束) 9 Transitioning Preparing new media item. 10 Ready Ready to begin playing.(准备就绪) 11 Reconnecting Reconnecting to stream.(重新连接)
*/ //判断视频是否已停止播放 if ((int)windowsMediaPlay.playState == 1) { //停顿2秒钟再重新播放 System.Threading.Thread.Sleep(1000); //重新播放 windowsMediaPlay.Ctlcontrols.play(); } else if ((int)windowsMediaPlay.playState == 3) { windowsMediaPlay.fullScreen = true; } }

亲测,解决问题。

[Winform]Media Player组件全屏播放的设置

标签:dia   png   logs   define   运行时   pre   ssi   事件   运行   

原文地址:http://www.cnblogs.com/wolf-sun/p/7054473.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!