0

My following code plays the "fox village.mp4" video, which is commented out, but not the you tube link and gives this error: AddInstanceForFactory: No factory registered for id F8BB1C28-BAE8-11D6-9C31-00039315CD46

Please help if you can. Thanks!!

    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()

1 Answers1

0

The first thing you need to clear that AVPlayer does not have the capacity to play youtube video from URL.

Note:

One thing you need to keep in your mind, AVPlayer is able played video if URL is direct downloadable.

In your case, you need to go with below solutions

Solution: 1

To play a youtube video, You need to go with the WKWebView or WKWebView with iFrame

OR

I suggest you need to go with YTPlayerView

OR

How to embed a Youtube video into my app?

Community
  • 1
  • 1
Hitesh Surani
  • 12,733
  • 6
  • 54
  • 65