When using AVPlayerItemLegibleOutput
to obtain a sequence of subtitles from a video stream the results are returned as NSAttributedString
s through AVPlayerItemLegibleOutputPushDelegate
method:
func legibleOutput(
_: AVPlayerItemLegibleOutput,
didOutputAttributedStrings strings: [NSAttributedString],
nativeSampleBuffers _: [Any],
forItemTime itemTime: CMTime
)
Inspecting the string's attributes I see that rather than NSAttributedString.Key
values such as NSAttributedString.Key.font
, NSAttributedString.Key.foregroundColor
we have Core Media attributes such as CMFontFamilyName
and CMForegroundColorARGB
.
As these attributes reflect the user's device accessibility settings for subtitles and closed-captions they should not be ignored. Unfortunately UILabel
cannot render them.
So my question is what is the correct approach to rendering these strings (when automatic player caption rendering isn't suitable)?