如何在Android中隐藏pip上的播放按钮?

ny6fqffe  于 2023-03-16  发布在  Android
关注(0)|答案(2)|浏览(172)

如你所见,我想隐藏这三个按钮的图片中的图片,有什么办法吗?
下面是我的pip代码:

private lazy var playerLayer: AVPlayerLayer = {
    let layer = AVPlayerLayer()
    
    let mp4Video = Bundle.main.url(forResource: "v1", withExtension: "MP4")
    let asset = AVAsset.init(url: mp4Video!)
    let playerItem = AVPlayerItem.init(asset: asset)
    
    let player = AVPlayer.init(playerItem: playerItem)
    layer.player = player
    player.isMuted = true
    player.allowsExternalPlayback = false
    
    
    return layer
}()

private lazy var pipVC: AVPictureInPictureController = {
    let vc = AVPictureInPictureController.init(playerLayer: playerLayer)
    vc?.delegate = self
    return vc!
}()
xfyts7mz

xfyts7mz1#

您至少可以通过以下方式隐藏搜索按钮:

vc.requiresLinearPlayback = true

其中,vc是您的AVPictureInPictureController示例。
如果你已经找到了隐藏播放按钮的方法,请分享它。

kmpatx3s

kmpatx3s2#

if #available(iOS 14.0, *) {
            //Hide the seekbar
            pipController?.requiresLinearPlayback = true
        } else {
            // Fallback on earlier versions
        }
        
        //Hide the play/pause controls
        pipController?.setValue(1, forKey: "controlsStyle")

相关问题