ios - 如何禁用 AVPlayerViewController 中的音频和字幕设置

标签 ios avplayerviewcontroller

我想从播放器(iOS8、iOS9)中删除音频和字幕设置按钮:

controls of the AVPlayerViewController player

播放器的 Controller 初始化:

            - (void) configureMoviePlayer {


                if(self.moviePlayerController == nil) {

                    self.moviePlayerController = [[AVPlayerViewController alloc] init];

                    [self.view setTranslatesAutoresizingMaskIntoConstraints:NO];
                    [self.moviePlayerController.view setTranslatesAutoresizingMaskIntoConstraints:NO];

                    [self.view addSubview: [self.moviePlayerController view]];

                    NSDictionary *views = @{ @"selfview" : self.view, @"movieControllerView" : [self moviePlayerController].view};

                    [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[movieControllerView]|"
                                                                                      options:0
                                                                                      metrics:nil
                                                                                        views:views]];
                    [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[movieControllerView]|"
                                                                                      options:0
                                                                                      metrics:nil
                                                                                        views:views]];
                }

            }

当收到流 URL 时,它被传递给一个新的播放器实例:

 self.moviePlayerController.player = [AVPlayer playerWithURL:self.contentUrl];
 //self.moviePlayerController.showsPlaybackControls = YES;
 if([self.moviePlayerController respondsToSelector:@selector(allowsPictureInPicturePlayback)]) {                             

    self.moviePlayerController.allowsPictureInPicturePlayback = YES;
}

例子in the WWDC video不包含按钮。有没有办法只禁用单个按钮,或者获取默认工具栏按钮的数组并禁用特定按钮。

最佳答案

在我们的案例中,此处的信息删除了不需要的按钮 https://developer.apple.com/library/content/qa/qa1801/_index.html

您需要明确声明内容不包含隐藏式字幕(使用 CLOSED-CAPTIONS=NONE,上面的注释中有完整的详细信息)

关于ios - 如何禁用 AVPlayerViewController 中的音频和字幕设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34028105/

相关文章:

ios - 图表中选定切片的颜色

ios - 连续多个 NSURLConnection

iphone - 服务器无法识别 iPhone 中 HTTP header SOAPAction 的值?

ios - 嵌套的 AVPlayer 全屏?

iOS:在锁定屏幕上使用控件时,AVPlayer 会播放多个音频实例

iphone - UISegmentedControl 非常奇怪的问题

ios - 在以下情况下应该使用哪个 In App Purchase?

ios - 我希望状态栏在全屏视频播放期间可见

tvOS AVPlayerViewController视频信息

ios - AVPlayerViewController 无法通过 url 播放视频