How to load MPMoviePlayerController contentUrl asynchronous when loading view?

前端 未结 1 1367
耶瑟儿~
耶瑟儿~ 2021-01-25 17:49

I try to play a video using a MPMoviePlayerController. The setup is: I push a new ViewController, then set up the view and the movie player instance in viewDidLoad and then use

相关标签:
1条回答
  • 2021-01-25 18:35

    I am not sure if this was a bug in the Swift betas or iOS 8 betas, but changing the code to use AVPlayer worked.

    import AVFoundation
    import AVKit
    
    let playerViewController = AVPlayerViewController()
    
    // In async block:
    
    if let player = AVPlayer.playerWithURL(url) as? AVPlayer {
        playerViewController.player = player
    }
    
    0 讨论(0)
提交回复
热议问题