Merge pull request #2215 from valtech-sd/master
Resolved ignored silent switch in iOS when player is set to paused
This commit is contained in:
commit
bf11502fdb
@ -918,6 +918,7 @@ static int const RCTVideoUnset = -1;
|
||||
- (void)setIgnoreSilentSwitch:(NSString *)ignoreSilentSwitch
|
||||
{
|
||||
_ignoreSilentSwitch = ignoreSilentSwitch;
|
||||
[self configureAudio];
|
||||
[self applyModifiers];
|
||||
}
|
||||
|
||||
@ -933,29 +934,8 @@ static int const RCTVideoUnset = -1;
|
||||
[_player pause];
|
||||
[_player setRate:0.0];
|
||||
} else {
|
||||
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];
|
||||
}
|
||||
[self configureAudio];
|
||||
|
||||
if (@available(iOS 10.0, *) && !_automaticallyWaitsToMinimizeStalling) {
|
||||
[_player playImmediatelyAtRate:_rate];
|
||||
@ -1089,6 +1069,33 @@ static int const RCTVideoUnset = -1;
|
||||
[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 {
|
||||
_repeat = repeat;
|
||||
}
|
||||
@ -1130,12 +1137,20 @@ static int const RCTVideoUnset = -1;
|
||||
}
|
||||
}
|
||||
} else { // default. invalid type or "system"
|
||||
#if TARGET_OS_TV
|
||||
// Do noting. Fix for tvOS native audio menu language selector
|
||||
#else
|
||||
[_player.currentItem selectMediaOptionAutomaticallyInMediaSelectionGroup:group];
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if TARGET_OS_TV
|
||||
// Do noting. Fix for tvOS native audio menu language selector
|
||||
#else
|
||||
// If a match isn't found, option will be nil and text tracks will be disabled
|
||||
[_player.currentItem selectMediaOption:mediaOption inMediaSelectionGroup:group];
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)setSelectedAudioTrack:(NSDictionary *)selectedAudioTrack {
|
||||
|
Loading…
Reference in New Issue
Block a user