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

Guilherme Dellagustin commented on CB-12877:
--------------------------------------------

After some research it became clear to me that this behavior happens because 
Android will close the app when memory is low.

I think the only way to avoid it would be to encapsulate the audio player(s) 
into a service.
This has its own problems though, as you would not be able to react to events 
in your JS code when the app is closed but the service remains (i.e.: persist 
data using js code when audio ended).

Aside from that, you would not have any means to control the audio when app is 
gone, at least not with the existing plugins (in my case I use 
cordova-plugin-music-controls, and the audio control goest through the JS code).

In other words, the only way I see that a cordova app could be a realiable 
audio player in Android at the moment, is to a android specific customized 
plugin that would delegate audio playing, control and eventual persistency to 
native code.

> (Android) Audio stops playing randomly on background
> ----------------------------------------------------
>
>                 Key: CB-12877
>                 URL: https://issues.apache.org/jira/browse/CB-12877
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: cordova-plugin-media
>    Affects Versions: 6.5.0
>         Environment: android 6.0, tested on Motorola Moto X 2d gen 
> http://www.gsmarena.com/motorola_moto_x_(2nd_gen)-6649.php
>            Reporter: Guilherme Dellagustin
>            Priority: Minor
>
> When audio is playing on background, it does not prevent the application from 
> eventually being closed by the OS.
> When this happens, I do not get any pop up like "unfortunally ... stoped 
> responding".
> I have some native apps that play audio on the background, where I never 
> observed this behavior.
> I have <preference name="KeepRunning" value="true" /> in the config file, and 
> the following plugins
>     <plugin name="cordova-plugin-inappbrowser" spec="~1.7.0" />
>     <plugin name="cordova-plugin-buildinfo" spec="~1.1.0" />
>     <plugin name="cordova-universal-links-plugin" spec="~1.2.1" />
>     <plugin name="cordova-plugin-browsertab" spec="~0.2.0" />
>     <plugin name="cordova-sqlite-storage" spec="~2.0.3" />
>     <plugin name="cordova-plugin-music-controls" spec="~1.4.1" />
>     <plugin name="cordova-plugin-x-toast" spec="~2.6.0" />
>     <plugin name="cordova-plugin-device" spec="~1.1.6" />



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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to