2

I've created my own video player using AVPlayer and have gotten everything to work properly except for closed captions. I have a video I'm testing and I know for a fact the closed captions are not baked in. I can disable them in other video viewers.

closedCaptionDisplayEnabled

I have that property on the AVPlayer set to NO and have logged it to make sure it is set to no but the captions still appear. Does anyone know why this might be?

user3527820
  • 33
  • 2
  • 5
  • This is answer. https://stackoverflow.com/questions/33303052/how-to-enable-disable-device-wise-closed-caption-settings-on-ios – Rakshit Korat Nov 24 '21 at 13:19

5 Answers5

8

Yes.

This is the right way :

let group = self.player!.currentItem!.asset.mediaSelectionGroupForMediaCharacteristic(AVMediaCharacteristicLegible)
self.player?.currentItem?.selectMediaOption(nil, inMediaSelectionGroup: group!)
CZ54
  • 5,488
  • 1
  • 24
  • 39
4

I disable subtitle by below code snippet

let output = AVPlayerItemLegibleOutput.init()
    output.setDelegate(self, queue:DispatchQueue.main)
    output.suppressesPlayerRendering = true
    playerItem?.add(output)

You can check suppressesPlayerRendering api there

Hsiao-Ting
  • 3,456
  • 2
  • 15
  • 20
0

My first thought would be to go to Subtitles & Captioning (Settings -> General -> Accessibility -> Subtitles & Captioning Setting) and ensure that ‘Closed Captions + SDH’ is turned off. Even if you set closedCaptionDisplayEnabled to NO, this setting will override it.

You can test if this is enabled on a device within your code using UIAccessibilityIsClosedCaptioningEnabled() which will return a BOOL that is true if it is. However, this setting can not be change within an app.

BoardProgrammer
  • 185
  • 1
  • 6
  • You can navigate from the app to the Subtitles & Captioning (Settings -> General -> Accessibility -> Subtitles & Captioning Setting) using this code. Prompt the user to Turn off Subtile & Captioning. if UIAccessibilityIsClosedCaptioningEnabled() == true { let subtitlesURL = NSURL(string:"prefs:root=General&path=ACCESSIBILITY/SUBTITLES_CAPTIONING") if UIApplication.sharedApplication().canOpenURL(subtitlesURL!) { UIApplication.sharedApplication().openURL(subtitlesURL!) } } – Taimur Ajmal Jun 23 '16 at 10:44
0

This works MACaptionAppearanceSetDisplayType(kMACaptionAppearanceDomainUser, kMACaptionAppearanceDisplayTypeForcedOnly);

Matthew
  • 4,935
  • 5
  • 21
  • 17
0

On Objective C you can do to disable close caption.

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