gpt4 book ai didi

swift - 按下 Siri 远程菜单按钮停止视频播放

转载 作者:行者123 更新时间:2023-11-28 08:33:13 26 4
gpt4 key购买 nike

在我的应用程序中,我确实播放了具有该功能的视频

func easyRandom_play(episodeTitle:String){
self.backgroundMusic?.stop()
backgroundMusic?.stop()
let link = "http://46.235.26.87/\(__TITLENAME_FOLDERNAME_DOWNLOAD__)/\(episodeTitle).m4v"
print(link)

let url:NSURL = NSURL(string: link)!
let player = AVPlayer(URL: url)
let playerViewController = AVPlayerViewController()
playerViewController.player = player
self.presentViewController(playerViewController, animated: true) {
playerViewController.player!.play()
}
}

现在没有办法停止视频 - 通常菜单按钮应该让我返回并结束播放。有什么办法可以实现吗?

最佳答案

您可以添加一个 UITapGestureRecognizer 来处理菜单按钮。

override func viewDidLoad() {
// Setup Menu Button recognizer
let menuGesture = UITapGestureRecognizer(target: self, action: #selector(ViewController.handleMenuGesture(_:)))
menuGesture.allowedPressTypes = [NSNumber(integer: UIPressType.Menu.rawValue)]
self.view.addGestureRecognizer(menuGesture)
}

func handleMenuGesture(tap: UITapGestureRecognizer) {
print("Menu Gesture")
// Stop video and dismiss view controller here
}

关于swift - 按下 Siri 远程菜单按钮停止视频播放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38412473/

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