Home:ALL Converter>AVPlayer Closed Captions turn on/off

AVPlayer Closed Captions turn on/off

Ask Time:2017-10-04T23:46:55         Author:Maor

Json Formatter

I'm creating custom video player, and i want to create toggle button for CC.

I saw this post : IOS AVPlayer cannot disable closed captions

So I tried :

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

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

Didn't work.. cc still visible.

also tried :

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

It's hide the the cc, but how can I unhide them? ,I tried:

[output setSuppressesPlayerRendering:true];

but the cc freeze on the screen.

thanks!

Author:Maor,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/46569048/avplayer-closed-captions-turn-on-off
yy