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

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

GitHub user tbrebant opened a pull request:

    https://github.com/apache/cordova-plugin-media/pull/100

    CB-7684: (iOS) Fix CDVSound killing all audio when a single file finishes

    ### Platforms affected
    
    iOS
    
    ### What does this PR do?
    
    We arrived to the same conclusion as Nathan Stryker on Jira 
(https://issues.apache.org/jira/browse/CB-7684) and @ionut-movila in the PR 
https://github.com/apache/cordova-plugin-media/pull/33 : all `self.avSession 
setActive:NO` should be removed.
    
    The problem was not only that when a media finishes it is stopping other 
ones played by the plugin, but it is also killing any sound played by another 
plugin or by WebView's default webaudio system, triggering a descriptive:
    ```
    AVAudioSession.mm:646: -[AVAudioSession setActive:withOptions:error:]: 
Deactivating an audio session that has running I/O. All I/O should be stopped 
or paused prior to deactivating the audio session.
    ```
    We found that `AVAudioSession` is a singleton for the whole app (cf. 
https://developer.apple.com/library/ios/documentation/AVFoundation/Reference/AVAudioSession_ClassReference/).
    
    Apple says:
    
    > Most apps never need to deactivate their audio session explicitly. 
Important exceptions include VoIP (Voice over Internet Protocol) apps, 
turn-by-turn navigation apps, and, in some cases, recording apps.
    
    (cf. 
https://developer.apple.com/library/ios/documentation/Audio/Conceptual/AudioSessionProgrammingGuide/ConfiguringanAudioSession/ConfiguringanAudioSession.html)
    
    ### What testing has been done on this change?
    
    - Played multiple sounds (non streaming) with the plugin, then waited for 
one to stop: it is not stopping other sounds anymore.
    - Played multiple sounds (non streaming) with the plugin, then stopped one 
and released it: it is not stopping other sounds anymore.
    - Played a sound (non streaming) with the plugin and another one via 
webview's webaudio, then waited the one played by the plugin to end: it is not 
stopping other sounds anymore.
    - Played a sound (non streaming) with the plugin and another one via 
webview's webaudio, then stopped and released the one played by the plugin: it 
is not stopping other sounds anymore.
    - Checked all possibilities with Xcode monitoring application: no memory 
issue detected.
    
    Ran the integrated tests. Before doing any change (version 2.3.1-dev) the 
result was:
    
    ![cordova-media-plugin 2 3 
1-dev](https://cloud.githubusercontent.com/assets/637734/16144330/252582c8-34ad-11e6-9932-cdb8ce8e05e5.jpg)
    
    After the change the result is exactly the same:
    
    ![cordova-media-plugin 
cb-7684](https://cloud.githubusercontent.com/assets/637734/16144343/35490008-34ad-11e6-98bd-90d7c86becc3.jpg)
    
    Before merging, it would be great if someone can test:
    - an application using the recording feature
    - an application using the streaming feature
    
    ### Checklist
    - [x] [ICLA](http://www.apache.org/licenses/icla.txt) has been signed and 
submitted to secret...@apache.org.
    - [x] [Reported an issue](http://cordova.apache.org/contribute/issues.html) 
in the JIRA database
    - [x] Commit message follows the format: "CB-3232: (android) Fix bug with 
resolving file paths", where CB-xxxx is the JIRA ID & "android" is the platform 
affected.
    - [ ] Added automated test coverage as appropriate for this change.
    
    About the last point: I don't see what kind of tests we can add for this 
fix.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/tbrebant/cordova-plugin-media CB7684

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/cordova-plugin-media/pull/100.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #100
    
----
commit 40a561d87fcebb5114fbdc01e6dafd6c617956fc
Author: tbrebant <tbreb...@wizcorp.jp>
Date:   2016-06-10T07:35:01Z

    CB-7684: (iOS) Fix CDVSound killing all audio when a single file finishes

----


> [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: 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.3.4#6332)

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

Reply via email to