UIWebview 方向景观中的 HTML 5 视频

发布于 2024-09-15 20:32:18 字数 218 浏览 7 评论 0原文

我有一个 iPhone 应用程序,其中每个视图都是纵向的。我有一个 UIWebview,里面有一些 HTML。其中有一个 html5 标记的视频。当我播放该视频时,它仅以纵向播放。为了使其在横向工作,我必须在视图控制器中为 shouldAutorotateToInterfaceOrientation 返回 YES,但我不希望视图控制器旋转到横向。我只希望视频支持横向。

有可能吗?

谢谢!

I have an iPhone application where every view is in portrait. I have a UIWebview with some HTML in it. Amoung that there is a html5 tagged video. When I play that video, it plays in portrait only. In order to make it work in landscape I have to return YES for shouldAutorotateToInterfaceOrientation in the viewcontroller, but I don't want the viewcontroller to rotate to landscape. I only want the video to support landscape orientation.

It is possible?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

自在安然 2024-09-22 20:32:18

我有同样的问题,有趣的是,如果您使用嵌入标签而不是视频标签,它可以工作,但您不会得到漂亮的图像!

<embed src='yourmovie.mp4' width='280px'></embed>

I have the same problem, interestingly though if you use embed tags instead of video tags it works but you dont get the nice image!

<embed src='yourmovie.mp4' width='280px'></embed>
累赘 2024-09-22 20:32:18

如果您有可用的 javascript 或其他脚本引擎,您是否尝试过为视频元素和嵌入元素提供 id 属性并使用 javascript 访问 DOM 来调整属性?

<body>
<video id="myvideo" width="240" height="320" src="a.vp8">
    <embed id="myvideoe" width="240" height="320" src="a.vp8">
</video>
<script type="text/javascript">
if (window.screen.width < window.screen.height) {
    //portrait
    document.getElementById('myvideo').setAttribute('width', 240);
    document.getElementById('myvideo').setAttribute('height', 320);
    document.getElementById('myvideoe').setAttribute('width', 240);
    document.getElementById('myvideoe').setAttribute('height', 320);
} else {
    //landscape
    document.getElementById('myvideo').setAttribute('width', 320);
    document.getElementById('myvideo').setAttribute('height', 240);
    document.getElementById('myvideoe').setAttribute('width', 320);
    document.getElementById('myvideoe').setAttribute('height', 240);
}
//or simply do this if you have differing size target screens:
//you can always subtract out the space for the controls.
document.getElementById('myvideo').setAttribute('width', window.screen.width);
document.getElementById('myvideo').setAttribute('height', window.screen.height);
document.getElementById('myvideoe').setAttribute('width', window.screen.width);
document.getElementById('myvideoe').setAttribute('height', window.screen.height);
</script>
</body>

如果您正在谈论将 src 更改为完全不同的横向或纵向视频,那也是可能的。我认为这可能只有通过提供 javascript 的 PhoneGap 才能实现。

if you have javascript available to you or some other scripting engine, have you tried giving the video element and embed element an id attribute and accessing the DOM using javascript to tweak the attributes?

<body>
<video id="myvideo" width="240" height="320" src="a.vp8">
    <embed id="myvideoe" width="240" height="320" src="a.vp8">
</video>
<script type="text/javascript">
if (window.screen.width < window.screen.height) {
    //portrait
    document.getElementById('myvideo').setAttribute('width', 240);
    document.getElementById('myvideo').setAttribute('height', 320);
    document.getElementById('myvideoe').setAttribute('width', 240);
    document.getElementById('myvideoe').setAttribute('height', 320);
} else {
    //landscape
    document.getElementById('myvideo').setAttribute('width', 320);
    document.getElementById('myvideo').setAttribute('height', 240);
    document.getElementById('myvideoe').setAttribute('width', 320);
    document.getElementById('myvideoe').setAttribute('height', 240);
}
//or simply do this if you have differing size target screens:
//you can always subtract out the space for the controls.
document.getElementById('myvideo').setAttribute('width', window.screen.width);
document.getElementById('myvideo').setAttribute('height', window.screen.height);
document.getElementById('myvideoe').setAttribute('width', window.screen.width);
document.getElementById('myvideoe').setAttribute('height', window.screen.height);
</script>
</body>

if you are talking about changing the src to an entirely different video that is landscape or portrait, that is possible too. I think this might be possible only with PhoneGap which provides javascript.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文