remove tracks that are not valid from textTracks; and default to system if selectedTextTrack unavailable
This commit is contained in:
parent
352bad21c4
commit
fa30fb3e43
@ -411,6 +411,7 @@ static int const RCTVideoUnset = -1;
|
|||||||
atTime:kCMTimeZero
|
atTime:kCMTimeZero
|
||||||
error:nil];
|
error:nil];
|
||||||
|
|
||||||
|
NSMutableArray* validTextTracks = [NSMutableArray array];
|
||||||
for (int i = 0; i < _textTracks.count; ++i) {
|
for (int i = 0; i < _textTracks.count; ++i) {
|
||||||
AVURLAsset *textURLAsset;
|
AVURLAsset *textURLAsset;
|
||||||
NSString *textUri = [_textTracks objectAtIndex:i][@"uri"];
|
NSString *textUri = [_textTracks objectAtIndex:i][@"uri"];
|
||||||
@ -420,6 +421,8 @@ static int const RCTVideoUnset = -1;
|
|||||||
textURLAsset = [AVURLAsset URLAssetWithURL:[self urlFilePath:textUri] options:nil];
|
textURLAsset = [AVURLAsset URLAssetWithURL:[self urlFilePath:textUri] options:nil];
|
||||||
}
|
}
|
||||||
AVAssetTrack *textTrackAsset = [textURLAsset tracksWithMediaType:AVMediaTypeText].firstObject;
|
AVAssetTrack *textTrackAsset = [textURLAsset tracksWithMediaType:AVMediaTypeText].firstObject;
|
||||||
|
if (!textTrackAsset) continue; // fix when there's no textTrackAsset
|
||||||
|
[validTextTracks addObject:[_textTracks objectAtIndex:i]];
|
||||||
AVMutableCompositionTrack *textCompTrack = [mixComposition
|
AVMutableCompositionTrack *textCompTrack = [mixComposition
|
||||||
addMutableTrackWithMediaType:AVMediaTypeText
|
addMutableTrackWithMediaType:AVMediaTypeText
|
||||||
preferredTrackID:kCMPersistentTrackID_Invalid];
|
preferredTrackID:kCMPersistentTrackID_Invalid];
|
||||||
@ -428,6 +431,9 @@ static int const RCTVideoUnset = -1;
|
|||||||
atTime:kCMTimeZero
|
atTime:kCMTimeZero
|
||||||
error:nil];
|
error:nil];
|
||||||
}
|
}
|
||||||
|
if (validTextTracks.count != _textTracks.count) {
|
||||||
|
[self setTextTracks:validTextTracks];
|
||||||
|
}
|
||||||
|
|
||||||
return [AVPlayerItem playerItemWithAsset:mixComposition];
|
return [AVPlayerItem playerItemWithAsset:mixComposition];
|
||||||
}
|
}
|
||||||
@ -848,7 +854,10 @@ static int const RCTVideoUnset = -1;
|
|||||||
selectedTrackIndex = index;
|
selectedTrackIndex = index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else { // type "system"
|
}
|
||||||
|
|
||||||
|
// in the situation that a selected text track is not available (eg. specifies a textTrack not available)
|
||||||
|
if (![type isEqualToString:@"disabled"] && selectedTrackIndex == RCTVideoUnset) {
|
||||||
CFArrayRef captioningMediaCharacteristics = MACaptionAppearanceCopyPreferredCaptioningMediaCharacteristics(kMACaptionAppearanceDomainUser);
|
CFArrayRef captioningMediaCharacteristics = MACaptionAppearanceCopyPreferredCaptioningMediaCharacteristics(kMACaptionAppearanceDomainUser);
|
||||||
NSArray *captionSettings = (__bridge NSArray*)captioningMediaCharacteristics;
|
NSArray *captionSettings = (__bridge NSArray*)captioningMediaCharacteristics;
|
||||||
if ([captionSettings containsObject:AVMediaCharacteristicTranscribesSpokenDialogForAccessibility]) {
|
if ([captionSettings containsObject:AVMediaCharacteristicTranscribesSpokenDialogForAccessibility]) {
|
||||||
|
Loading…
Reference in New Issue
Block a user