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

摘要

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

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

MSDN

Remarks

For full-screen mode to work properly when embedding the Windows Media Player control, the video display area must have a height and width of at least one pixel. If uiMode is set to "mini" or "full", the height of the control itself must be 65 or greater to accommodate the video display area in addition to the user interface.

If uiMode is set to "invisible", then setting this property to true raises an error and does not affect the behavior of the control.

During full-screen playback, Windows Media Player hides the mouse cursor when enableContextMenu equals false and uiMode equals "none".

If uiMode is set to "full" or "mini", Windows Media Player displays transport controls in full-screen mode when the mouse cursor moves. After a brief interval of no mouse movement, the transport controls are hidden. If uiMode is set to "none", no controls are displayed in full-screen mode.

Note  Displaying transport controls in full-screen mode requires the Windows XP operating system.
 

If transport controls are not displayed in full-screen mode, then Windows Media Player automatically exits full-screen mode when playback stops.

参考

https://msdn.microsoft.com/en-us/library/windows/desktop/dd562419(v=vs.85).aspx

1、基本属性  URL 指定媒体位置,本机或网络地址 例如:axWindowsMediaPlayer1.URL = @"f:\aa.mp3"; uiMode 播放器界面模式,可为Full, Mini, None, Invisible ;Full:有下面的控制条; None:只有播放部份没有控制条 例如:axWindowsMediaPlayer1.uiMode = "Invisible"; playState 播放状态,1=停止,2=暂停,3=播放,6=正在缓冲,9=正在连接,10=准备就绪 enableContextMenu 启用/禁用右键菜单 fullScreen 是否全屏显示 stretchToFit 非全屏状态时是否伸展到最佳大小 2、播放器基本控制 Ctlcontrols.play(); 播放 Ctlcontrols.pause(); 暂停 Ctlcontrols.stop(); 停止 Ctlcontrols.currentPosition 当前进度 Ctlcontrols.currentPositionString 当前进度,字符串格式。如“00:23” Ctlcontrols.fastForward(); 快进 Ctlcontrols.fastReverse(); 快退 Ctlcontrols.next(); 下一曲 Ctlcontrols.previous(); 上一曲 3、播放器基本设置 settings.volume 音量,0-100 settings.balance 声道,通过它应该可以进行立体声、左声道、右声道的控制。 settings.autoStart 是否自动播放 settings.mute 是否静音 settings.playCount 播放次数 settings.rate 播放速度 4、当前媒体属性 currentMedia.duration 媒体总长度 currentMedia.durationString 媒体总长度,字符串格式。如“03:24” currentMedia.getItemInfo(const string) 获取当前媒体信息"Title"=媒体标题,"Author"=艺术家,"Copyright"=版权信息,"Description"=媒体内容描述,"Duration"=持续时间(秒),"FileSize"=文件大小,"FileType"=文件类型,"sourceURL"=原始地址 currentMedia.setItemInfo(const string) 通过属性名设置媒体信息 currentMedia.name 同 currentMedia.getItemInfo("Title")
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值