From 9ad11dd5698c256b913ca5d7ec4086e427659610 Mon Sep 17 00:00:00 2001 From: Hampton Maxwell Date: Wed, 20 Jun 2018 15:26:24 -0700 Subject: [PATCH] Avoid crash when text track doesn't have a title or language --- ios/RCTVideo.m | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ios/RCTVideo.m b/ios/RCTVideo.m index d2cc3114..5fd921cd 100644 --- a/ios/RCTVideo.m +++ b/ios/RCTVideo.m @@ -702,13 +702,16 @@ static NSString *const timedMetadata = @"timedMetadata"; 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]; + NSString *title = @""; + NSArray *values = [[currentOption commonMetadata] valueForKey:@"value"]; + if (values.count > 0) { + title = [values objectAtIndex:0]; + } + NSString *language = [currentOption extendedLanguageTag] ? [currentOption extendedLanguageTag] : @""; NSDictionary *textTrack = @{ @"index": [NSNumber numberWithInt:i], @"title": title, - @"language": [currentOption extendedLanguageTag] + @"language": language }; [textTracks addObject:textTrack]; }