摘要

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

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 == )
{
//停顿2秒钟再重新播放
System.Threading.Thread.Sleep();
//重新播放
windowsMediaPlay.Ctlcontrols.play();
}
else if ((int)windowsMediaPlay.playState == )
{
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. 一次奇怪的T-shirt展示
  2. ajava包的命名
  3. javascript 搜索二叉树
  4. ADO.NET基础01
  5. lnmp+phpmyadmin配置与出现问题
  6. jQuery基础 - 改变CSS样式
  7. Linux命令(6):mv命令
  8. Python中替换元素
  9. linux压缩与解压缩 tar命令
  10. bzoj1232
  11. Hello China操作系统STM32移植指南(一)
  12. redis sets类型及操作
  13. (转)Oracle中的rownum,ROWID的 用法
  14. wampserver安装
  15. 利用maven将项目打包成一个可以运行的独立jar包
  16. struts Action设置数据的方法
  17. 在没有任何投票节点情况下将从节点转换为Primary节点脚本
  18. 在Jmeter中用JAVA获取Rolling Date
  19. 解决火狐浏览器发送jquery的ajax请求无效的问题
  20. 映射函数map

热门文章

  1. ispoweroftwo 判断2的次幂【转】
  2. linux驱动---等待队列、工作队列、Tasklets【转】
  3. mysql5.7.20:安装教程
  4. hashlib和hmac
  5. 修改MySQL的时区,涉及参数time_zone
  6. Oracle ORA-12541:TNS:无监听程序
  7. mysql存储表情字符
  8. 标签流 VS 脚本流
  9. Python学习笔记:算法的重要性
  10. Java编程的逻辑 (5) - 小数计算为什么会出错?