1

When the accessibility option is turned on the device, we're not able to turn off the closed caption by setting the closedCaptionEnabled option for the AVPlayer instance as we normally would. Is there a way to bypass such option or even to test if it's enabled to lock the CC button if necessary?

Bruno Machado - vargero
  • 2,690
  • 5
  • 33
  • 52
  • May I know which version of iOS you are using? Are you purely using AVPlayer or you may have another player, such Brightcove, which has AVPlayer embedded inside? – Navid Rezaei Nov 17 '15 at 17:56

1 Answers1

2

You can iterate through each AVPlayerItemTrack and enable/disable it as you wish.

This is how I do in one of my project. I show table of available CC tracks and when the user selects one I iterate through each track, enable the on that user selected and disable rest.

    //_selectedTrackIndex = userSelectedIndex;
    -(void) setSelectedTrackEnabled {
        for (AVPlayerItemTrack * t in [_playerItem tracks]) {
            if (counter == _selectedTrackIndex) {
                [t setEnabled:YES];
            } else {
                [t setEnabled:NO];
            }
        }
    }
dev
  • 2,180
  • 2
  • 30
  • 46
  • 1
    This works great for switching between tracks. However if I disable all the tracks to turn off CC, the most recent caption gets stuck on the screen and doesn't disappear. Does anyone know how to handle this? – Cobar Jul 30 '18 at 19:26