Airplay按钮未在AVPlayer的播放器控件中显示

时间:2016-03-03 11:51:13

标签: ios swift ios9 airplay

我使用AVPlayer和AVPlayerViewController创建了一个视频播放器。我将“allowsExternalPlayback”属性设置为true,并将“usesExternalPlaybackWhileExternalScreenIsActive”属性设置为true。但我仍然没有在播放器控件中获得Airplay图标。

player = AVPlayer(URL: url!)
player!.allowsExternalPlayback = true
player?.usesExternalPlaybackWhileExternalScreenIsActive = true

我在ios 9.2上运行我的应用程序。

2 个答案:

答案 0 :(得分:2)

答案 1 :(得分:1)

func appleTv()
    {
        let rect = CGRect(x: -100, y: 0, width: 0, height: 0)
        let airplayVolume = MPVolumeView(frame: rect)
        airplayVolume.showsVolumeSlider = false
        self.view.addSubview(airplayVolume)
        for view: UIView in airplayVolume.subviews {
            if let button = view as? UIButton {
                button.sendActions(for: .touchUpInside)
                break
            }
        }
        airplayVolume.removeFromSuperview()
    }