I was able to display a subtitle track with AVPlayer
on iOS 6, but I am not able to customize it. It just shows the same style (a small font size, in white).
Here's how I select the subtitle:
AVMediaSelectionGroup *subtitle = [asset mediaSelectionGroupForMediaCharacteristic: AVMediaCharacteristicLegible];
[self.videoPlayer.currentItem selectMediaOption:subtitle.options[0] inMediaSelectionGroup: subtitle];
And how I'm trying to customize the subtitle:
AVTextStyleRule *rule = [[AVTextStyleRule alloc] initWithTextMarkupAttributes:@{
(id)kCMTextMarkupAttribute_ForegroundColorARGB : @[ @1, @1, @0, @0 ],
(id) kCMTextMarkupAttribute_ItalicStyle : @(YES)}];
self.videoPlayer.currentItem.textStyleRules = @[rule];
No matter if I put this snippet before or after selecting the subtitle, the result is the same.
The AVPlayer
is created with a local (file) URL (a mp4 file).
Any thoughts on how to do this?
I found workaround to modify text foreground color and background correctly. Just separate styles to multiple AVTextStyleRule.
please do not ask me why, that solution come from try and error XD
I asked this question on Apple Developer Forums and I got an answer from an Apple employee:
So, I'll open a radar to ask that they update the docs and I'll post its number here if someone wants to dupe it.
EDIT:
I created rdar://14923673 to ask Apple to update the docs about this current limitation. I also created rdar://14923755 to ask them to provide support to subtitles in TX3G format.
Please dupe them if you're affected by this issue.