WebBrowser控制视频元素进入全屏 [英] WebBrowser control video element enter fullscreen

查看:189
本文介绍了WebBrowser控制视频元素进入全屏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中,我有一个带有视频元素的 WebBrowser 控件,我想插入一个按钮,当我按下它时,视频元素将切换到全屏模式。

In my project, I have a WebBrowser control with a video element and I want to insert a button that when I press it, the video element will switch to fullscreen mode.

我试过这段代码:

var video = document.getElementById('video');

if (video.requestFullscreen) {
    video.requestFullscreen();
} else if (video.mozRequestFullScreen) {
    video.mozRequestFullScreen();
} else if (video.webkitRequestFullscreen) {
    video.webkitRequestFullscreen();
}

它不起作用。我在一些文章中读到,在IE浏览器中不可能使视频元素进入全屏。有没有解决这个问题?我做错了吗?

And it won't work. I read in some article that it's not possible in IE browser to make video element enter fullscreen. Is there any fix for this? Did I do something wrong?

推荐答案

根据 MSDN ,我们应该能够处理 OnFullScreen 事件并跟踪 FullScreen 属性 WebBrowser 控件。您需要为此访问基础ActiveX对象。我自己没有尝试 FullScreen / OnFullScreen

According to MSDN, we should be able to handle the OnFullScreen event and track the FullScreen property of WebBrowser control. You'd need to access the underlying ActiveX object for that. I haven't tried FullScreen/OnFullScreen myself, though.

[更新] 不幸的是, OnFullScreen 没有当通过< video> 元素的原生用户界面输入全屏模式时, WebBrowser 被解雇我刚刚验证了。 IE的对象模型 code>< video> 元素似乎没有任何与全屏模式相关的方法/属性/事件。因此,< video> 元素的程序化大小调整可能是最佳选择。

[UPDATE] Unfortunately, OnFullScreen doesn't get fired for WebBrowser when full-screen mode is entered via the native UI of the <video> element, I've just verified that. The object model of IE <video> element doesn't seem to have any methods/properties/events related to full-screen mode, either. So, programmatic resizing of the <video> element would probably be the best option.

这篇关于WebBrowser控制视频元素进入全屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆