Draw button on top of AVPlayer

前端 未结 5 2077
执念已碎
执念已碎 2020-12-28 09:29

I have to draw a label or button on top of video relay next previous , leave comment . List of video have it, once user select one item from the table,it need t

5条回答
  •  轮回少年
    2020-12-28 10:09

    I recommend looking up AVPlayerLayer as a way to show buttons and other content on top of your video.

    See the Advances in AVFoundation Playback WWDC presentation.

    Also, check out the AVFoundationSimplePlayer-iOS example project.

    Essentially, you create a view to host your player, and you make the layer behind the view into an AVPlayerLayer.

    class PlayerView: UIView {
        var player: AVPlayer? {
            get {
                return playerLayer.player
            }
    
            set {
                playerLayer.player = newValue
            }
        }
    
        var playerLayer: AVPlayerLayer {
            return layer as! AVPlayerLayer
        }
    
        override class var layerClass: AnyClass {
            return AVPlayerLayer.self
        }
    }
    

提交回复
热议问题