how to play a video in UIView swift?

后端 未结 3 1882
我寻月下人不归
我寻月下人不归 2021-02-03 10:14

I have a video which I want to download from a server and stream it in a fixed view. I\'ve set a UIView in my storyboard with fixed constraints, and here is what I\'ve done in c

3条回答
  •  悲哀的现实
    2021-02-03 10:35

    the only way to add a video to a UIView with fixed constraints in storyboard, was this :

    let url = URL(string:myURL)
    
    player = AVPlayer(url: url!)
    
    avpController.player = player
    
    avpController.view.frame.size.height = videoView.frame.size.height
    
    avpController.view.frame.size.width = videoView.frame.size.width
    
    self.videoView.addSubview(avpController.view)
    

    I hope other can use this! :)

提交回复
热议问题