如何在应用程序中打开YouTube视频?

时间:2018-08-09 11:12:51

标签: ios swift youtube

我想在我的应用中播放youtube视频。但是我想通过单击图像(按钮)将视频打开到全屏。我不想创建UIWebview。有可能吗?

2 个答案:

答案 0 :(得分:1)

使用此广告连播:XCDYouTubeKit

func StartVideo() {

        let ViodeoViewController = AVPlayerViewController()
        self.present(ViodeoViewController, animated: true, completion: nil)

        XCDYouTubeClient.default().getVideoWithIdentifier("KHIJmehK5OA") { (video: XCDYouTubeVideo?, error: Error?) in
            if let streamURL = video?.streamURLs[XCDYouTubeVideoQuality.HD720.rawValue] {
                ViodeoViewController.player = AVPlayer(url: streamURL)
            } else {
                self.dismiss(animated: true, completion: nil)
            }
        }
}

您还可以在库的帮助下更改其他配置设置。

答案 1 :(得分:1)

请点击以下链接:

这是youtube提供的帮助程序,您可以安装此pod并可以使用第二个链接来了解如何集成到您的应用中

https://github.com/youtube/youtube-ios-player-helper

https://developers.google.com/youtube/v3/guides/ios_youtube_helper

相关问题