IOS AVPlayer cannot disable closed captions

倾然丶 夕夏残阳落幕 提交于 2019-12-20 07:01:12

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!