溶液をAVPlayerViewController
の基本クラスを作成し、touchesBegan(_:with:)メソッドをオーバーライドすることである
let videoURL = NSURL(string: "https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4")
let player = AVPlayer(URL: videoURL!)
let playerViewController = CustomAVPlayerViewController()
playerViewController.player = player
self.presentViewController(playerViewController, animated: true) {
playerViewController.player!.play()
}
スウィフト3:
カスタム基本クラス:
class CustomAVPlayerViewController: AVPlayerViewController {
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
print("touchesBegan")
}
}
ビューコントローラ:
let videoURL = URL(string: "https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4")
let player = AVPlayer(url: videoURL!)
let playerViewController = CustomAVPlayerViewController()
playerViewController.player = player
self.present(playerViewController, animated: true) {
playerViewController.player!.play()
}
はimport AVKit
とimport AVFoundation
に忘れないでください。
playerViewController
をタップするたびに「touchesBegan」が印刷されます。
ユーザーが前/後ボタンを押したときにタッチを検出する方法はありますか? – pkc456