【问题标题】:Error while playing You Tube videos in IOS Swift app在 IOS Swift 应用中播放 Youtube 视频时出错
【发布时间】:2020-08-05 01:47:19
【问题描述】:

我的以下代码播放“fox village.mp4”视频,该视频已被注释掉,但不是你管链接并给出此错误: AddInstanceForFactory:没有为 id F8BB1C28-BAE8-11D6-9C31-00039315CD46 注册工厂

如果可以,请提供帮助。谢谢!!

    let videoURL = URL(string: "https://youtu.be/MTNCcC_H3oM")!


    //   let videoURL = URL(string: "https://wolverine.raywenderlich.com/content/ios/tutorials/video_streaming/foxVillage.mp4")!

    let player =  AVPlayer(url: videoURL)


    let playerViewController = AVPlayerViewController()
    playerViewController.player = player

    present(playerViewController, animated: true) {
      player.play()

【问题讨论】:

    标签: ios swift youtube


    【解决方案1】:

    首先您需要明确的是,AVPlayer 无法播放来自URL 的 youtube 视频。

    注意:

    您需要记住一件事,如果URL 可以直接下载,AVPlayer 可以播放视频。

    在您的情况下,您需要使用以下解决方案

    解决方案:1

    要播放 youtube 视频,您需要使用 WKWebViewWKWebViewiFrame

    我建议你需要使用YTPlayerView

    How to embed a Youtube video into my app?

    【讨论】:

      猜你喜欢
      • 2017-01-30
      • 2013-12-19
      • 1970-01-01
      • 2017-02-10
      • 2015-05-20
      • 2017-05-12
      • 2015-11-16
      • 1970-01-01
      • 2017-05-20
      相关资源
      最近更新 更多