cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CB-7684) [Media] CDVSound Kills any and all playing sound files when a single file finishes
Date Sat, 06 Jan 2018 00:16:00 GMT

    [ https://issues.apache.org/jira/browse/CB-7684?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16314190#comment-16314190
] 

ASF GitHub Bot commented on CB-7684:
------------------------------------

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


> [Media] CDVSound Kills any and all playing sound files when a single file finishes
> ----------------------------------------------------------------------------------
>
>                 Key: CB-7684
>                 URL: https://issues.apache.org/jira/browse/CB-7684
>             Project: Apache Cordova
>          Issue Type: Sub-task
>          Components: cordova-plugin-media
>    Affects Versions: 3.5.0
>         Environment: iOS
>            Reporter: Nathan Stryker
>
> The CDVSound file will kill all playing media files when ever a single file completes
playing. The issue is around like 691 in the method "AudioDidFinishPlaying", with the code:
>     if (self.avSession) {
>         [self.avSession setActive:NO error:nil];
> }
> The reason I think this is a bug is that if a user as Music file A playing in a loop
and Music file B plays, when B completes the "setActive:NO" will kill the avSession of both
A and B. 



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Mime
View raw message