Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 2 additions & 21 deletions src/ios/CDVSound.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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];
}
Expand All @@ -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];
}
Expand Down Expand Up @@ -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];
}

Expand All @@ -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];
}

Expand All @@ -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];
}

Expand Down