diff --git a/ios/RCTVideo.m b/ios/RCTVideo.m index 253f48da..d2cc3114 100644 --- a/ios/RCTVideo.m +++ b/ios/RCTVideo.m @@ -415,6 +415,7 @@ static NSString *const timedMetadata = @"timedMetadata"; @"height": height, @"orientation": orientation }, + @"textTracks": [self getTextTrackInfo], @"target": self.reactTag}); } @@ -694,6 +695,26 @@ static NSString *const timedMetadata = @"timedMetadata"; [_player.currentItem selectMediaOption:option inMediaSelectionGroup:group]; } +- (NSArray *)getTextTrackInfo +{ + NSMutableArray *textTracks = [[NSMutableArray alloc] init]; + AVMediaSelectionGroup *group = [_player.currentItem.asset + mediaSelectionGroupForMediaCharacteristic:AVMediaCharacteristicLegible]; + for (int i = 0; i < group.options.count; ++i) { + AVMediaSelectionOption *currentOption = [group.options objectAtIndex:i]; + NSString *title = [[[currentOption commonMetadata] + valueForKey:@"value"] + objectAtIndex:0]; + NSDictionary *textTrack = @{ + @"index": [NSNumber numberWithInt:i], + @"title": title, + @"language": [currentOption extendedLanguageTag] + }; + [textTracks addObject:textTrack]; + } + return textTracks; +} + - (BOOL)getFullscreen { return _fullscreenPlayerPresented;