IOS AVPlayer cannot disable closed captions

后端 未结 4 1116
感情败类
感情败类 2021-01-27 13:01

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 cl

相关标签:
4条回答
  • 2021-01-27 13:22

    Yes.

    This is the right way :

    let group = self.player!.currentItem!.asset.mediaSelectionGroupForMediaCharacteristic(AVMediaCharacteristicLegible)
    self.player?.currentItem?.selectMediaOption(nil, inMediaSelectionGroup: group!)
    
    0 讨论(0)
  • 2021-01-27 13:23

    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

    0 讨论(0)
  • 2021-01-27 13:36

    This works MACaptionAppearanceSetDisplayType(kMACaptionAppearanceDomainUser, kMACaptionAppearanceDisplayTypeForcedOnly);

    0 讨论(0)
  • 2021-01-27 13:38

    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.

    0 讨论(0)
提交回复
热议问题