Report textTracks in onLoad

This commit is contained in:
Hampton Maxwell 2018-06-11 20:55:23 -07:00
parent 8aac3dd905
commit a1a4e0c44b

View File

@ -415,6 +415,7 @@ static NSString *const timedMetadata = @"timedMetadata";
@"height": height, @"height": height,
@"orientation": orientation @"orientation": orientation
}, },
@"textTracks": [self getTextTrackInfo],
@"target": self.reactTag}); @"target": self.reactTag});
} }
@ -694,6 +695,26 @@ static NSString *const timedMetadata = @"timedMetadata";
[_player.currentItem selectMediaOption:option inMediaSelectionGroup:group]; [_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 - (BOOL)getFullscreen
{ {
return _fullscreenPlayerPresented; return _fullscreenPlayerPresented;