在iOS应用中播放YouTube视频 [英] To play Youtube Video in iOS app

查看:816
本文介绍了在iOS应用中播放YouTube视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的iOS应用中播放youtube视频.我进行了搜索,但发现的唯一解决方案是将youtube视频嵌入到iOS应用中,该视频在Webview中播放,因此,我们可以滚动并播放建议的其他视频. 我不想在Webview中播放视频,我想像在播放器中播放视频一样播放视频,并且用户无法滚动它. 在Swift中有什么解决方案吗?我也不想使用违反Youtube条款和条件的库

I want to play youtube videos in my iOS App. I searched for that but the only solution I found is to embed youtube videos in the iOS app, in which video plays in webview, so in that, we can scroll and also play other videos which are in suggestion. I don't want to play video in webview, I want to play video just like it plays in player and user cannot scroll it. Is there any solution for that in Swift and also I don't want to use libraries which are against terms and condition of Youtube

推荐答案

如果您不想使用YouTube提供的API,而是继续使用UIWebView.这是另一个解决方案.

Here's another solution if you don't want to use the API provided by YouTube and instead continue using a UIWebView.

YouTube具有使用格式为https://www.youtube.com/embed/<videoId>的URL在Webview中全屏加载任何视频而无需任何滚动功能的功能.

YouTube has functionality to load any video in fullscreen in a webview without any of the scrolling features using a URL in the format https://www.youtube.com/embed/<videoId>.

例如,要使用此方法加载江南风格,只需将UIWebView定向到URL https://www.youtube.com/embed/9bZkp7q19f0 .

For example, to load Gangnam Style using this method, simply direct the UIWebView to the URL https://www.youtube.com/embed/9bZkp7q19f0.

这篇关于在iOS应用中播放YouTube视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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