画中画按钮已禁用
Picture in picture button disabled
我正在开发实时视频播放器,我想使用新的画中画选项。我将播放器基于 AVPlayerViewController,这是我的代码。
class PlayerViewController: AVPlayerViewController {
var link = NSURL ()
override func viewDidLoad() {
super.viewDidLoad()
setVideoPlayer()
do {
try AVAudioSession.sharedInstance().setActive(true)
try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback)
}
catch {
print("Audio session setCategory failed")
}
}
}
typealias VideoPlayer = PlayerViewController
extension VideoPlayer {
func setVideoPlayer() {
player = AVPlayer(URL: (link))
player!.play()
}
}
我不明白为什么画中画在 iPad Air 2 模拟器上运行良好,但在真实设备中画中画按钮虽然可见但仍处于禁用状态,用户无法点击它。
确保在 AppDelegate.swift func application(application:, didFinishLaunchingWithOptions launchOptions:) 中设置音频会话,在示例代码下方找到。
let audioSssn = AVAudioSession.sharedInstance();
do {
try audioSssn.setCategory(AVAudioSessionCategoryPlayback)
}
catch {
print("Audio session setCategory failed")
}
我正在开发实时视频播放器,我想使用新的画中画选项。我将播放器基于 AVPlayerViewController,这是我的代码。
class PlayerViewController: AVPlayerViewController {
var link = NSURL ()
override func viewDidLoad() {
super.viewDidLoad()
setVideoPlayer()
do {
try AVAudioSession.sharedInstance().setActive(true)
try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback)
}
catch {
print("Audio session setCategory failed")
}
}
}
typealias VideoPlayer = PlayerViewController
extension VideoPlayer {
func setVideoPlayer() {
player = AVPlayer(URL: (link))
player!.play()
}
}
我不明白为什么画中画在 iPad Air 2 模拟器上运行良好,但在真实设备中画中画按钮虽然可见但仍处于禁用状态,用户无法点击它。
确保在 AppDelegate.swift func application(application:, didFinishLaunchingWithOptions launchOptions:) 中设置音频会话,在示例代码下方找到。
let audioSssn = AVAudioSession.sharedInstance();
do {
try audioSssn.setCategory(AVAudioSessionCategoryPlayback)
}
catch {
print("Audio session setCategory failed")
}