【问题标题】:AVPlayer: Close button doesn't work on iOS 16AVPlayer:关闭按钮在 iOS 16 上不起作用
【发布时间】:2022-09-27 15:48:45
【问题描述】:

我在 iOS 16 上遇到问题,关闭按钮不会像往常一样关闭 AVPlayer,但它可以在 iOS 12 上运行。

你知道我错过了什么吗?

func didTapOnPlay(url: URL) {
    let player = AVPlayer(url: url)
    playerViewController.player = player
    
    NotificationCenter.default.addObserver(
        self,
        selector: #selector(playerDidReachEndNotificationHandler),
        name: NSNotification.Name(rawValue: \"AVPlayerItemDidPlayToEndTimeNotification\"),
        object: player.currentItem)
    
    router.present(playerViewController, animated: false) { [weak self] in
        self?.playerViewController.player?.play()
    }
}
  • 您的代码中似乎没有关闭按钮。你可以添加其余的代码吗?
  • 谢谢你的帮助。我只是在调用函数 didTapOnPlay 之前初始化了一个 AVPlayerViewController (playerViewController = AVPlayerViewController()) 我没有配置关闭按钮,因为已经在 AVPlayerViewController 上设置了但是当我可以点击它时,iOS 16 上没有任何反应(按预期关闭工作iOS 15 - 12) 是否必须配置关闭按钮?

标签: swift


【解决方案1】:

我认为这是 iOS 16 的错误,因为当我将动画参数设置为 true 时,它​​正在工作

router.present(playerViewController, animated: true) { [weak self] in
        self?.playerViewController.player?.play()
    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-06-13
    • 1970-01-01
    • 2022-09-27
    • 1970-01-01
    • 2017-02-22
    • 1970-01-01
    • 2022-11-02
    • 2012-11-06
    相关资源
    最近更新 更多