added an onCaptionsDeviceSettings event

This commit is contained in:
Ash Mishra
2018-08-27 10:42:49 -07:00
parent 37c31a3c92
commit 77c48c9dfc
4 changed files with 18 additions and 3 deletions

View File

@@ -68,6 +68,7 @@ static int const RCTVideoUnset = -1;
#if __has_include(<react-native-video/RCTVideoCache.h>)
RCTVideoCache * _videoCache;
#endif
BOOL _deviceCaptionsEnabled;
}
- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher
@@ -364,6 +365,12 @@ static int const RCTVideoUnset = -1;
@"target": self.reactTag
});
}
if (self.onCaptionsDeviceSetting) {
self.onCaptionsDeviceSetting(@{@"deviceCaptionsEnabled": [NSNumber numberWithBool:_deviceCaptionsEnabled],
@"target": self.reactTag
});
}
}];
});
_videoLoadStarted = YES;
@@ -966,9 +973,7 @@ static int const RCTVideoUnset = -1;
// 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);
NSArray *captionSettings = (__bridge NSArray*)captioningMediaCharacteristics;
if ([captionSettings containsObject:AVMediaCharacteristicTranscribesSpokenDialogForAccessibility]) {
if (_deviceCaptionsEnabled) {
selectedTrackIndex = 0; // If we can't find a match, use the first available track
NSString *systemLanguage = [[NSLocale preferredLanguages] firstObject];
for (int i = 0; i < textTracks.count; ++i) {