how to play a video in UIView swift?

后端 未结 3 1880
我寻月下人不归
我寻月下人不归 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条回答
  •  梦毁少年i
    2021-02-03 10:44

    You can try to use AVPlayerLayer in a AVPlayer.

          let player = AVPlayer(url: video) // your video url
          let playerLayer = AVPlayerLayer(player: player)
          playerLayer.frame = videoView.bounds
          videoView.layer.addSublayer(playerLayer)
          player.play()
    

提交回复
热议问题