gpt4 book ai didi

iOS:外部显示器 AVPlayerController 关闭问题

转载 作者:行者123 更新时间:2023-11-30 10:55:55 31 4
gpt4 key购买 nike

我遇到了与此问题相同的问题,但我不知道我错在哪里。

它仍然保留在外部显示器上视频的最后一帧。

iOS Swift App AVPlayerController dismiss not working on external display

不幸的是,我没有足够的声誉点来评论其他问题。

是因为我没有AVPlayerItem吗?

let fourVideoViewController = AVPlayerViewController()    

@IBAction func fourVideoPlayButton(_ sender: Any) {

let fourVideoURL = Bundle.main.url(forResource: "Four Animation",
withExtension: "mov")!
let fourPlayer = AVPlayer(url: fourVideoURL as URL)

fourVideoViewController.player = fourPlayer

NotificationCenter.default.addObserver(self, selector:
#selector(playerDidFinishPlaying), name:
NSNotification.Name.AVPlayerItemDidPlayToEndTime, object:
fourVideoViewController.player?.currentItem)

self.present(fourVideoViewController, animated: true) {
self.fourVideoViewController.player!.play()
}
}


@objc func playerDidFinishPlaying(note: NSNotification) {

fourVideoViewController.dismiss(animated: true, completion: nil)
fourVideoViewController.view.removeFromSuperview()
self.presentedViewController?.dismiss(animated: true, completion: nil)
}

最佳答案

您可以尝试在 playerDidFinishPlaying 函数中关闭

self.navigationController?.popToRootViewController(animated: true)

或者

self.view.window!.rootViewController?.dismiss(动画:true,完成:nil)

关于iOS:外部显示器 AVPlayerController 关闭问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53953009/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com