AVPlayer具有avplayerviewcontroller的播放控件 [英] AVPlayer with playback controls of avplayerviewcontroller
问题描述
我将n avplayer放在视图控制器中以自定义视图控制器的其他一些元素,但我仍然想要AVPlayerViewController中使用的播放和清理控件。当我没有使用AvPlayerViewcontroller时,有没有办法为Avplayer启用这些控件?
I am putting n avplayer inside of a view controller to customize some other elements of the view controller but I still want the playback and scrubbing controls used in AVPlayerViewController. Is there a way to enable these controls for the Avplayer when I am not using AvPlayerViewcontroller?
推荐答案
否。通常的解决方案(Apple明确建议)是使用AVPlayerViewController作为嵌入式视图控制器 - 即,使您的视图控制器成为自定义父视图控制器,将AVPlayerViewController作为其子视图,现在您可以放置其视图(电影和控件)在你的视图中作为一个良好的子视图。示例(来自我的书; self
是您的视图控制器):
No. The usual solution (explicitly advised by Apple) is to use the AVPlayerViewController as an embedded view controller - i.e., make your view controller a custom parent view controller and the AVPlayerViewController its child, and now you can place its view (the movie and the controls) inside your view as a subview in good order. Example (from my book; self
is your view controller):
let url = // whatever
let player = AVPlayer(URL:url)
let av = AVPlayerViewController()
av.player = player
av.view.frame = // whatever
self.addChildViewController(av)
self.view.addSubview(av.view)
av.didMoveToParentViewController(self)
这篇关于AVPlayer具有avplayerviewcontroller的播放控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!