【问题标题】:AVPlayer Closed Captions turn on/offAVPlayer 隐藏式字幕打开/关闭
【发布时间】:2017-10-04 15:46:55
【问题描述】:

我正在创建自定义视频播放器,我想为 CC 创建切换按钮。

我看到了这个帖子:IOS AVPlayer cannot disable closed captions

所以我尝试了:

AVMediaSelectionGroup *group = [self.avPlayer.currentItem.asset mediaSelectionGroupForMediaCharacteristic:AVMediaCharacteristicLegible];

[self.avPlayer.currentItem  selectMediaOption:nil inMediaSelectionGroup:group];

没用.. cc 仍然可见。

也试过了:

AVPlayerItemLegibleOutput *output = [[AVPlayerItemLegibleOutput alloc] init];
[output setDelegate:self queue:dispatch_get_main_queue()];
[output setSuppressesPlayerRendering:true];
[self.avPlayer.currentItem addOutput:output];

它隐藏了抄送,但我怎样才能取消隐藏呢? ,我试过了:

[output setSuppressesPlayerRendering:true];

但 cc 在屏幕上冻结。

谢谢!

【问题讨论】:

标签: ios objective-c avplayer


【解决方案1】:

目标 C:这个对我有用。甚至我也想做同样的事情。

关闭字幕

AVMediaSelectionGroup *subtitleSelectionGroup = [_playerItem.asset mediaSelectionGroupForMediaCharacteristic:AVMediaCharacteristicLegible];
              
[_playerItem selectMediaOption:NULL inMediaSelectionGroup:subtitleSelectionGroup];

为了再次显示它,我这样做:

AVMediaSelectionOption* option = [subtitleSelectionGroup.options objectAtIndex:subtitleIndex-1]; // I did -1 because OFF was 0 for my case 
         
[_playerItem selectMediaOption:option inMediaSelectionGroup:subtitleSelectionGroup];
   

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-07-14
    • 1970-01-01
    • 2015-08-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多