Resolved an issue where setting a video to paused would ignore the “silent switch” setting
This commit is contained in:
		| @@ -915,6 +915,7 @@ static int const RCTVideoUnset = -1; | |||||||
| - (void)setIgnoreSilentSwitch:(NSString *)ignoreSilentSwitch | - (void)setIgnoreSilentSwitch:(NSString *)ignoreSilentSwitch | ||||||
| { | { | ||||||
|   _ignoreSilentSwitch = ignoreSilentSwitch; |   _ignoreSilentSwitch = ignoreSilentSwitch; | ||||||
|  |   [self configureAudio]; | ||||||
|   [self applyModifiers]; |   [self applyModifiers]; | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -930,29 +931,8 @@ static int const RCTVideoUnset = -1; | |||||||
|     [_player pause]; |     [_player pause]; | ||||||
|     [_player setRate:0.0]; |     [_player setRate:0.0]; | ||||||
|   } else { |   } else { | ||||||
|     AVAudioSession *session = [AVAudioSession sharedInstance]; |  | ||||||
|     AVAudioSessionCategory category = nil; |  | ||||||
|     AVAudioSessionCategoryOptions options = nil; |  | ||||||
|  |  | ||||||
|     if([_ignoreSilentSwitch isEqualToString:@"ignore"]) { |     [self configureAudio]; | ||||||
|       category = AVAudioSessionCategoryPlayback; |  | ||||||
|     } else if([_ignoreSilentSwitch isEqualToString:@"obey"]) { |  | ||||||
|       category = AVAudioSessionCategoryAmbient; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     if([_mixWithOthers isEqualToString:@"mix"]) { |  | ||||||
|       options = AVAudioSessionCategoryOptionMixWithOthers; |  | ||||||
|     } else if([_mixWithOthers isEqualToString:@"duck"]) { |  | ||||||
|       options = AVAudioSessionCategoryOptionDuckOthers; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     if (category != nil && options != nil) { |  | ||||||
|       [session setCategory:category withOptions:options error:nil]; |  | ||||||
|     } else if (category != nil && options == nil) { |  | ||||||
|       [session setCategory:category error:nil]; |  | ||||||
|     } else if (category == nil && options != nil) { |  | ||||||
|       [session setCategory:session.category withOptions:options error:nil]; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     if (@available(iOS 10.0, *) && !_automaticallyWaitsToMinimizeStalling) { |     if (@available(iOS 10.0, *) && !_automaticallyWaitsToMinimizeStalling) { | ||||||
|       [_player playImmediatelyAtRate:_rate]; |       [_player playImmediatelyAtRate:_rate]; | ||||||
| @@ -1086,6 +1066,33 @@ static int const RCTVideoUnset = -1; | |||||||
|   [self setAllowsExternalPlayback:_allowsExternalPlayback]; |   [self setAllowsExternalPlayback:_allowsExternalPlayback]; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | - (void)configureAudio | ||||||
|  | { | ||||||
|  |     AVAudioSession *session = [AVAudioSession sharedInstance]; | ||||||
|  |     AVAudioSessionCategory category = nil; | ||||||
|  |     AVAudioSessionCategoryOptions options = nil; | ||||||
|  |  | ||||||
|  |     if([_ignoreSilentSwitch isEqualToString:@"ignore"]) { | ||||||
|  |       category = AVAudioSessionCategoryPlayback; | ||||||
|  |     } else if([_ignoreSilentSwitch isEqualToString:@"obey"]) { | ||||||
|  |       category = AVAudioSessionCategoryAmbient; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     if([_mixWithOthers isEqualToString:@"mix"]) { | ||||||
|  |       options = AVAudioSessionCategoryOptionMixWithOthers; | ||||||
|  |     } else if([_mixWithOthers isEqualToString:@"duck"]) { | ||||||
|  |       options = AVAudioSessionCategoryOptionDuckOthers; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     if (category != nil && options != nil) { | ||||||
|  |       [session setCategory:category withOptions:options error:nil]; | ||||||
|  |     } else if (category != nil && options == nil) { | ||||||
|  |       [session setCategory:category error:nil]; | ||||||
|  |     } else if (category == nil && options != nil) { | ||||||
|  |       [session setCategory:session.category withOptions:options error:nil]; | ||||||
|  |     } | ||||||
|  | } | ||||||
|  |  | ||||||
| - (void)setRepeat:(BOOL)repeat { | - (void)setRepeat:(BOOL)repeat { | ||||||
|   _repeat = repeat; |   _repeat = repeat; | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user