我可以在 UIWebView 内联(不是全屏)中播放 youtube 视频吗? [英] Can I play a youtube video in a UIWebView inline (not fullscreen)?

查看:30
本文介绍了我可以在 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?

我已将allowInlineMediaPlayback 设置为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="https://www.youtube.com/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 视频吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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