1
我正在使用蘋果電視。我的UIViewController裏面有一個UIView。我將AVPlayerViewController添加爲我的UIView的子視圖。 UIView的框架是CGRect(x:50,y:50,寬度:1344,高度:756)。我設置AVPlayerViewController框架等於我的UIView框架。視圖內的AVPlayerViewController未顯示播放控件
問題是視頻在其框架中播放良好,但暫停,播放,轉發等控件被隱藏,無法正常工作。但是當我設置框架爲CGRect(x:0,y:0,寬度:1920,高度:1080)時,控件可見且正在工作。
我的代碼是按照下文:
let url = URL(string: "https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4")
let item = AVPlayerItem(url: url!)
self.player = AVPlayer(playerItem: item)
self.avplayerController = AVPlayerViewController()
self.avplayerController.player = self.player
self.avplayerController.view.frame = videoPreviewLayer.frame
self.avplayerController.showsPlaybackControls = true
self.avplayerController.requiresLinearPlayback = true
self.addChildViewController(self.avplayerController)
self.view.addSubview(self.avplayerController.view)
self.avpController.player?.play()
請幫助。
嘿感謝間隙大衛。當空間小於全屏時,我能以任何方式顯示avplayer的控件嗎? – Ruchi
@Ruchi是的,你可以在AVPlayer的實例上添加自定義視圖,從AVPlayer屬性中獲取信息,但不可能使用本地AVPlayerViewController。 –
好的。你知道任何第三方庫或框架嗎?我搜查了但沒有找到一個。 – Ruchi