问题
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?
回答1:
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
回答2:
Yes.
This is the right way :
let group = self.player!.currentItem!.asset.mediaSelectionGroupForMediaCharacteristic(AVMediaCharacteristicLegible)
self.player?.currentItem?.selectMediaOption(nil, inMediaSelectionGroup: group!)
回答3:
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.
回答4:
This works MACaptionAppearanceSetDisplayType(kMACaptionAppearanceDomainUser, kMACaptionAppearanceDisplayTypeForcedOnly);
来源:https://stackoverflow.com/questions/34777781/ios-avplayer-cannot-disable-closed-captions