ios – 如何在AVPlayerViewController中禁用音频和字幕设置

前端之家收集整理的这篇文章主要介绍了ios – 如何在AVPlayerViewController中禁用音频和字幕设置前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想从播放器(iOS8,iOS9)中删除音频和字幕设置按钮:

controls of the AVPlayerViewController player

玩家的控制器初始化:

- (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相关文章