【问题标题】:HTML 5 video in UIWebview Orientation landscapeUIWebview 方向景观中的 HTML 5 视频
【发布时间】:2010-08-23 23:42:20
【问题描述】:

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

有可能吗?

谢谢!

【问题讨论】:

    标签: iphone video uiwebview orientation landscape


    【解决方案1】:

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

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

    【讨论】:

    • 用 quicktime 播放视频,需要安装 quicktime 插件。聪明的主意。我只是希望它不依赖插件。
    【解决方案2】:

    如果您有可用的 javascript 或其他脚本引擎,您是否尝试过为 video 元素和 embed 元素提供 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 才能实现。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-08-08
      • 2011-04-17
      • 1970-01-01
      • 1970-01-01
      • 2012-09-01
      • 1970-01-01
      • 2011-12-28
      相关资源
      最近更新 更多