You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2018/01/06 00:16:01 UTC
[GitHub] macdonst closed pull request #100: CB-7684: (iOS) Fix CDVSound killing all audio when a single file finishes
macdonst closed pull request #100: CB-7684: (iOS) Fix CDVSound killing all audio when a single file finishes
URL: https://github.com/apache/cordova-plugin-media/pull/100
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/src/ios/CDVSound.m b/src/ios/CDVSound.m
index df40d7de..552c72d1 100644
--- a/src/ios/CDVSound.m
+++ b/src/ios/CDVSound.m
@@ -180,7 +180,7 @@ - (CDVAudioFile*)audioFileForResource:(NSString*)resourcePath withId:(NSString*)
return audioFile;
}
-// returns whether or not audioSession is available - creates it if necessary
+// returns whether or not audioSession is available - retrieve the instance (app singleton) if necessary
- (BOOL)hasAudioSession
{
BOOL bSession = YES;
@@ -191,7 +191,7 @@ - (BOOL)hasAudioSession
self.avSession = [AVAudioSession sharedInstance];
if (error) {
// is not fatal if can't get AVAudioSession , just log the error
- NSLog(@"error creating audio session: %@", [[error userInfo] description]);
+ NSLog(@"error retrieving audio session: %@", [[error userInfo] description]);
self.avSession = nil;
bSession = NO;
}
@@ -447,9 +447,6 @@ - (BOOL)prepareToPlay:(CDVAudioFile*)audioFile withId:(NSString*)mediaId
if (playerError != nil) {
NSLog(@"Failed to initialize AVAudioPlayer: %@\n", [playerError localizedDescription]);
audioFile.player = nil;
- if (self.avSession) {
- [self.avSession setActive:NO error:nil];
- }
bError = YES;
} else {
audioFile.player.mediaId = mediaId;
@@ -586,7 +583,6 @@ - (void)release:(CDVInvokedUrlCommand*)command
avPlayer = nil;
}
if (self.avSession) {
- [self.avSession setActive:NO error:nil];
self.avSession = nil;
}
[[self soundCache] removeObjectForKey:mediaId];
@@ -685,9 +681,6 @@ - (void)startRecordingAudio:(CDVInvokedUrlCommand*)command
errorMsg = @"Failed to start recording using AVAudioRecorder";
}
audioFile.recorder = nil;
- if (weakSelf.avSession) {
- [weakSelf.avSession setActive:NO error:nil];
- }
jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%@);", @"cordova.require('cordova-plugin-media.Media').onStatus", mediaId, MEDIA_ERROR, [weakSelf createMediaErrorWithCode:MEDIA_ERR_ABORTED message:errorMsg]];
[weakSelf.commandDelegate evalJs:jsString];
}
@@ -705,9 +698,6 @@ - (void)startRecordingAudio:(CDVInvokedUrlCommand*)command
NSString* msg = @"Error creating audio session, microphone permission denied.";
NSLog(@"%@", msg);
audioFile.recorder = nil;
- if (weakSelf.avSession) {
- [weakSelf.avSession setActive:NO error:nil];
- }
jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%@);", @"cordova.require('cordova-plugin-media.Media').onStatus", mediaId, MEDIA_ERROR, [self createMediaErrorWithCode:MEDIA_ERR_ABORTED message:msg]];
[weakSelf.commandDelegate evalJs:jsString];
}
@@ -759,9 +749,6 @@ - (void)audioRecorderDidFinishRecording:(AVAudioRecorder*)recorder successfully:
// jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"cordova.require('cordova-plugin-media.Media').onStatus", mediaId, MEDIA_ERROR, MEDIA_ERR_DECODE];
jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%@);", @"cordova.require('cordova-plugin-media.Media').onStatus", mediaId, MEDIA_ERROR, [self createMediaErrorWithCode:MEDIA_ERR_DECODE message:nil]];
}
- if (self.avSession) {
- [self.avSession setActive:NO error:nil];
- }
[self.commandDelegate evalJs:jsString];
}
@@ -783,9 +770,6 @@ - (void)audioPlayerDidFinishPlaying:(AVAudioPlayer*)player successfully:(BOOL)fl
// jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"cordova.require('cordova-plugin-media.Media').onStatus", mediaId, MEDIA_ERROR, MEDIA_ERR_DECODE];
jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%@);", @"cordova.require('cordova-plugin-media.Media').onStatus", mediaId, MEDIA_ERROR, [self createMediaErrorWithCode:MEDIA_ERR_DECODE message:nil]];
}
- if (self.avSession) {
- [self.avSession setActive:NO error:nil];
- }
[self.commandDelegate evalJs:jsString];
}
@@ -795,9 +779,6 @@ -(void)itemDidFinishPlaying:(NSNotification *) notification {
NSString* jsString = nil;
jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%d);", @"cordova.require('cordova-plugin-media.Media').onStatus", mediaId, MEDIA_STATE, MEDIA_STOPPED];
- if (self.avSession) {
- [self.avSession setActive:NO error:nil];
- }
[self.commandDelegate evalJs:jsString];
}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org