Skip to content

Commit

Permalink
basic support for subtitles in an HLS stream
Browse files Browse the repository at this point in the history
  • Loading branch information
petrbela committed May 2, 2018
1 parent 737d348 commit ce01d5a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ios/RCTVideo.m
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,13 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N
orientation = @"portrait";
}

// TODO make it configurable to select a preferred subtitle language and turn them on/off
AVMediaSelectionGroup *subtitleGroup = [_playerItem.asset mediaSelectionGroupForMediaCharacteristic:AVMediaCharacteristicLegible];
NSArray<AVMediaSelectionOption *> *subtitles = [AVMediaSelectionGroup mediaSelectionOptionsFromArray:[subtitleGroup options] filteredAndSortedAccordingToPreferredLanguages:[NSLocale preferredLanguages]];
if (subtitles.count > 0) {
[_playerItem selectMediaOption:[subtitles objectAtIndex:0] inMediaSelectionGroup:subtitleGroup];
}

if(self.onVideoLoad) {
self.onVideoLoad(@{@"duration": [NSNumber numberWithFloat:duration],
@"currentTime": [NSNumber numberWithFloat:CMTimeGetSeconds(_playerItem.currentTime)],
Expand Down

0 comments on commit ce01d5a

Please sign in to comment.