How use app closedcaption settings instead of system closed caption settings in ios

∥☆過路亽.° 提交于 2019-12-25 03:22:28

问题


In my application i have closed caption settings and i am using AVPLayer to play video/live content without showing default controls. In my app i can able or disable closed captions like switch based on that switch status i am storing BOOL value in userdefaults. Based on userdefaults i am trying to enable or disable cc for avplayer using below api.

[self.player setClosedCaptionDisplayEnabled:enable];

Now problem is Even if i off cc in app but iphone system settings cc enabled that time i am getting cc in avplayer. If i off system cc then my app settings are effecting in avplayer.

Can you please suggest is there any way to bypass system settings for avplayer. If cannot can you please provide apple document link to show as a proof to clinet that we cannot do this like that.


回答1:


You should set

self.player.appliesMediaSelectionCriteriaAutomatically = FALSE;

Instead of this, which is deprecated.

[self.player setClosedCaptionDisplayEnabled:enable];

By default, AVPlayer applies selection criteria based on system preferences. To override the default criteria for any media selection group, use -[AVPlayer setMediaSelectionCriteria:forMediaCharacteristic:].

EDIT

This method will be used:

@method setMediaSelectionCriteria:forMediaCharacteristic:

@abstract Applies automatic selection criteria for media that has the specified media characteristic.

@param criteria An instance of AVPlayerMediaSelectionCriteria.

@param mediaCharacteristic The media characteristic for which the selection criteria are to be applied. Supported values include AVMediaCharacteristicAudible, AVMediaCharacteristicLegible, and AVMediaCharacteristicVisual.

@discussion Criteria will be applied to an AVPlayerItem when:

a) It is made ready to play

b) Specific media selections are made by -[AVPlayerItem selectMediaOption:inMediaSelectionGroup:] in a different group. The automatic choice in one group may be influenced by a specific selection in another group.

c) Underlying system preferences change, e.g. system language, accessibility captions.

Specific selections made by -[AVPlayerItem selectMediaOption:inMediaSelectionGroup:] within any group will override automatic selection in that group until -[AVPlayerItem selectMediaOptionAutomaticallyInMediaSelectionGroup:] is received.

  • (void)setMediaSelectionCriteria:(nullable AVPlayerMediaSelectionCriteria *)criteria forMediaCharacteristic:(AVMediaCharacteristic)mediaCharacteristic NS_AVAILABLE(10_9, 7_0);

Documentation for the same is here



来源:https://stackoverflow.com/questions/51551655/how-use-app-closedcaption-settings-instead-of-system-closed-caption-settings-in

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