Skip to content

not working with AVPlayerViewController #14

Description

@holyman2k
let playerViewController:AVPlayerViewController = AVPlayerViewController()
    let youtubeUrl = NSURL(string: "https://www.youtube.com/watch?v=vXjVFPosQHw")!
    Youtube.h264videosWithYoutubeURL(youtubeUrl) { [unowned self] (videoInfo, error) -> Void in
        if let videoURLString = videoInfo?["url"] as? String,
            videoTitle = videoInfo?["title"] as? String {
                print("\(videoTitle)")
                print("\(videoURLString)")

                if let url = NSURL(string:videoURLString) {
                    let playerItem = AVPlayerItem(URL: url)
                    let player = AVPlayer(playerItem: playerItem)
                    self.playerViewController.player = player;
                    self.addChildViewController(self.playerViewController);
                    self.playerViewController.view.frame = self.view.frame;
                    self.view.addSubview(self.playerViewController.view);
                    player.play()
                }
        }
    }
}

When the AVPlayerViewController is added to the view, it show a video as unplayable

img

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions