0 Replies
      Latest reply on Aug 13, 2019 4:18 PM by cabearsfan
      cabearsfan Level 1 Level 1 (0 points)

        I'm trying to update our app to stop using the deprecated methods for toggling Closed Captions on the AVPlayer. We're using the following logic to determine whether captions are currently displaying captions:

         

        if let group = self.playerItem.asset.mediaSelectionGroup(forMediaCharacteristic: AVMediaCharacteristic.legible),
             let optionGroup = self.playerItem.currentMediaSelection.selectedMediaOption(in: group)
        {
             return true
        }
        return false



        Then we use the inverse value of what the above method returns to toggle the captions on or off.

        let subtitlesGroup = self.playerItem.asset.mediaSelectionGroup(forMediaCharacteristic: .legible)
        // on
        self.playerItem.select(subtitlesGroup.options.first, in: subtitlesGroup)
        // off
        self.playerItem.select(nil, in: subtitlesGroup)



        When playing back on the device locally this works perfectly, but when we attempt to transition to playback over AirPlay, the first method always returns true regardless of whether or not captions are displaying. I've forced the 2nd method to switch between on/off using a local variable to ensure the commands would work, and they do, so the issue comes down to this line always returning a valid AVMediaSelectionOption while playing back via AirPlay

         

        self.playerItem.currentMediaSelection.selectedMediaOption(in: group)

         

        Anyone run into this issue? Any other value I should be checking instead when playing back via AirPlay?