Updated Branches: refs/heads/master f97d46166 -> b3177d223
Fixes CB-906 - Hardware mute button doesn't effect Media API playback Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/commit/b3177d22 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/tree/b3177d22 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/diff/b3177d22 Branch: refs/heads/master Commit: b3177d223dfd10245e7021cdd06901476a351415 Parents: f97d461 Author: Shazron Abdullah <[email protected]> Authored: Mon Jun 18 15:32:20 2012 -0700 Committer: Shazron Abdullah <[email protected]> Committed: Mon Jun 18 15:32:20 2012 -0700 ---------------------------------------------------------------------- CordovaLib/Classes/CDVSound.m | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/b3177d22/CordovaLib/Classes/CDVSound.m ---------------------------------------------------------------------- diff --git a/CordovaLib/Classes/CDVSound.m b/CordovaLib/Classes/CDVSound.m index 706ae30..ce2c3d0 100644 --- a/CordovaLib/Classes/CDVSound.m +++ b/CordovaLib/Classes/CDVSound.m @@ -177,7 +177,14 @@ // get the audioSession and set the category to allow Playing when device is locked or ring/silent switch engaged if ([self hasAudioSession]) { NSError* err = nil; - [self.avSession setCategory:AVAudioSessionCategoryPlayback error:nil]; + NSNumber* playAudioWhenScreenIsLocked = [options objectForKey:@"playAudioWhenScreenIsLocked"]; + BOOL bPlayAudioWhenScreenIsLocked = YES; + if (playAudioWhenScreenIsLocked != nil) { + bPlayAudioWhenScreenIsLocked = [playAudioWhenScreenIsLocked boolValue]; + } + + NSString* sessionCategory = bPlayAudioWhenScreenIsLocked? AVAudioSessionCategoryPlayback : AVAudioSessionCategorySoloAmbient; + [self.avSession setCategory:sessionCategory error:&err]; if (![self.avSession setActive: YES error: &err]){ // other audio with higher priority that does not allow mixing could cause this to fail NSLog(@"Unable to play audio: %@", [err localizedFailureReason]);
