摘要

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

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. linux笔记_day08

    1.文件权限管理 1)chown:改变文件属主(只有管理员才能使用这个命令)(change owner) chown USERNAME file... -R :修改目录以及内部文件的属主 --refe ...

  2. 【mongoDB】 分享系列

    mongoDB 作为一个非关系性数据库(功能很像关系型数据库) MongoDB 之一 MongoDB是什么 MongoDB 之二 增-删-改-查 MongoDB 之三 数据类型 MongoDB 之四 ...

  3. Nuts & Bolts Problem

    Given a set of n nuts of different sizes and n bolts of different sizes. There is a one-one mapping ...

  4. Linux 定时器应用【转】

    Linux 定时器应用 实验目的 阅读 Linux 相关源代码,学习 Linux 系统中的时钟和定时器原理,即,ITIMER_REAL实时计数,ITIMER_VIRTUAL 统计进程在用户模式执行的时 ...

  5. Linux监控重要进程的实现方法

    Linux监控重要进程的实现方法 不管后台服务程序写的多么健壮,还是可能会出现core dump等程序异常退出的情况,但是一般情况下需要在无 人为干预情况下,能够自动重新启动,保证服务进程能够服务用户 ...

  6. react-router 4 路由的嵌套

    1.在component组件内部需要嵌套的位置直接嵌套Route标签 这个方法会使得路由标签比较分散,子组件我们必须直接将Route标签写入到父组件之中,而且路由必须包含根路径. // Dashboa ...

  7. 说一下PHP中die()和exit()区别

    PHP手册:die()Equivalent to exit(). 说明:die()和exit()都是中止脚本执行函数:其实exit和die这两个名字指向的是同一个函数,die()是exit()函数的别 ...

  8. mysql5.6.34在默认配置文件修改字符集为utf8后重启mysql服务没效果

    1:事情是这样的,我下载了一个mysql5.6.34版本(windows版本的),下载下来后里面只有个my-default.ini,然后我就直接在my-default.ini 里面配置basedir, ...

  9. 【LOJ】#2533. 「CQOI2018」交错序列

    题解 有毒吧 这题\(O(n)\)过不去 非得写\(O((a + b)^3\log n)\)的矩乘,同样很卡常 把\(x\)换成\(n - y\) 我们拆完式子发现是这样的 \(\sum_{i = 0 ...

  10. Java8 Lambda 之 Collection Stream

    Lambda 之 Collection Stream Collection.stream() 测试实体类 class Demo { private Long id; private String na ...