摘要

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

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

[Winform]Media Player组件全屏播放的设置的更多相关文章

  1. winform下实现pictureBox全屏播放

    最近开发一个项目,需要通过双击pictureBox实现全屏的功能,网上查找资料,加上一点摸索,最终实现了.做一下记录,以备以后需要. 主要功能都在下面这个类里面 using System; using ...

  2. [Winform]Media Player com组件应用中遇到的问题

    摘要 最近一个项目中,需要用到在客户端全屏循环播放视频,当时考虑使用开源的播放器,但控制起来不方便,然后考虑既然都是windows系统,那么可以考虑使用微软自带的Media Player播放器.所以在 ...

  3. [转]Android WebView播放视频(包括全屏播放),androidwebview

    Android WebView播放视频(包括全屏播放),androidwebview 最近项目开发中用到了WebView播放视频的功能,总结了开发中犯过的错误,这些错误在开发是及容易遇到的,所以我这里 ...

  4. 【wpf基础】wpf MediaElement全屏播放视频功能

    最近在研究如何将视频全屏播放,一开始思路A:弹窗将MediaElement对象add到一个新的全屏窗体,报错 指定的元素已经是另一个元素的逻辑子元素.请先将其断开连接. 后续转换思路B:将本窗体其他控 ...

  5. uwp,c#,全屏播放保持屏幕响应

    在开发视频app的时候,全屏播放一段时间内没有电脑操作,电脑会自动进入睡眠模式,这时就要多写些代码来保持响应了. (这里使用的是MediaElement播放控件,MediaElement需要手动添加代 ...

  6. h5页面自动播放视频、音频_关于媒体文件自动全屏播放的实现方式

    在移动端(ios和android)播放视频的时候,我们即使定义了autoplay属性,仍然不能自动播放.这是由于手机浏览器为了防止浪费用户的网络流量,在默认情况下是不允许媒体文件自动播放的,除非用户自 ...

  7. 【Win 10应用开发】实现全屏播放的方法

    有人会问,以前的MediaElement控件不是有现成的一排操作按钮吗?而且可以直接进入全屏播放.是的,我们知道,以往的Store App都是在全屏模式下运行的,只要MediaElement控件填满整 ...

  8. iphone H5视频行内播放(禁止全屏播放)

    一般用户都知道,ios在网页点击视频播放时,视频会弹出全屏播放框. video标签的playsinline.webkit-playsinline标记根本就不会起作用. 还有传闻说对于没有声音的视频不会 ...

  9. HTML5新标签video在iOS上默认全屏播放

    今天做一个app时发现一个问题,应用html5中的video标签加载视频,在Android手机上默认播放大小,但是换成iPhone手机上出问题了,默认弹出全屏播放,查找了好多论坛,都没有谈论这个的.然 ...

随机推荐

  1. imperva代理拦截

    <external-traffic-monitoring-in-kern>true</external-traffic-monitoring-in-kern> 添加这段就可以开 ...

  2. springMVC版本和jdk版本不匹配造成的问题

    一个简单的例子项目,使用springMVC的版本是3.2,jdk的版本是1.7,使用的是注解的处理器适配器和处理器映射器.spring的xml配置文件中单独配置每个handler,可以正常的使用,如果 ...

  3. 首发:极简的Centos主机监控方法,分分钟即可使用【转】

    需求天天有,今年事更多.硬盘测试刚刚完成,就又来了性能监控的需求.一般我们生产就用zabbix了,用起来还行,就是蛮多脚本要写.开发和测试都是分散的,经常还要重装系统,用zabbix就算了,开发和测试 ...

  4. CentOS7.x使用overlay文件系统

    https://www.cnblogs.com/yufeng218/p/8370670.html http://www.cnblogs.com/lehuoxiong/p/9908118.html ht ...

  5. 【LOJ】#2585. 「APIO2018」新家

    题解 成功把自己写自闭了 离散化之后再二分我是真不会算坐标啊我这个zz 先离散化所有坐标,然后对于每个位置维护一个最小前驱,然后线段树区间维护最小前驱 什么?位置一样?那就给每个大小为1的位置开个mu ...

  6. 上海高校金马五校赛 J - 小Y写文章

    题目大意: 给你n个数字, 定义不连贯值为, max(abs(a[ i ] - b[ i ])) ,现在让你把m个新的数字插入n + 1 个空位中,使得不连贯值最小. 思路:二分不连贯值, 每次进行二 ...

  7. Vue $createElement

    const h=this.$createElement; h('span', tag, '内容可以是 ') ..... tag完整的数据对象如下: {    // 和`v-bind:class`一样的 ...

  8. oracle数据库连接错误解决办法

    ORA-28547 连接服务器失败,可能是Oracle Net 管理错误 原文地址:http://www.linuxidc.com/Linux/2014-11/109686.htm 上周去给客户培训O ...

  9. 001.VNC介绍

    一 VNC介绍 VNC 服务是一个自由开源软件,采用RFB通信协议.RFB ("remote 帧缓存 ") 是一个远程图形用户的简单协议,因为它工作在帧缓存级别上,所以它可以应用于 ...

  10. C++雾中风景10:聊聊左值,纯右值与将亡值

    C++11的版本在类型系统上下了很大的功夫,添加了诸如auto,decltype,move等新的关键词来简化代码的编写与降低阅读代码的难度.为了更好的理解这些新的语义,笔者确定通过几篇文章来简单窥探一 ...