我可以在 UIWebView 内联(非全屏)中播放 youtube 视频吗?

编程入门 行业动态 更新时间:2024-10-25 00:32:27
本文介绍了我可以在 UIWebView 内联(非全屏)中播放 youtube 视频吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我到处寻找如何做到这一点,但还没有找到答案.是否可以在 iPhone 内嵌的 UIWebView 中播放 youtube 视频,即不是全屏?我知道 iPhone 不支持 Flash,但 youtube 支持 html5 并且有 h.264 视频不是吗?那我不应该这样做吗?

I have looked everywhere on how to do this and haven't found an answer yet. Is it possible to play a youtube video in a UIWebView on an iPhone inline, i.e. not fullscreen? I know that the iPhone doesn't support flash, but youtube supports html5 and has h.264 videos doesn't it? shouldn't I be able to do this then?

我已将 allowedInlineMediaPlayback 设置为 YES,但它仍然可以全屏播放.

I have set allowsInlineMediaPlayback to YES, but still it plays fullscreen.

推荐答案

可以,你需要在 UIWebView 上设置属性

Yes you can, you need to set property on UIWebView

webView.allowsInlineMediaPlayback=YES;

并且您需要将 &playsinline=1 添加到 YouTube iframe 嵌入代码中.

And you need to add &playsinline=1 to YouTube iframe embedding code.

<iframe webkit-playsinline width="200" height="200" src="www.youtube/embed/GOiIxqcbzyM?feature=player_detailpage&playsinline=1" frameborder="0"></iframe>

在运行 iOS 6.1.2 的 iPhone 4S 上进行测试,效果非常好.

Tested on iPhone 4S running iOS 6.1.2 works like a charm.

更多推荐

我可以在 UIWebView 内联(非全屏)中播放 youtube 视频吗?

本文发布于:2023-07-11 12:23:57,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1094051.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:内联   全屏   视频   UIWebView   youtube

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!