cordova-plugin-media icon indicating copy to clipboard operation
cordova-plugin-media copied to clipboard

feat: Implement playing audio in background

Open adriano-di-giovanni opened this issue 5 years ago • 4 comments

Platforms affected

  • Android
  • iOS

On iOS, I only added a startPlayingAudioInBackground that's a proxy tostartPlayingAudio because the latter already plays the audio in a background thread.

Motivation and Context

Playing audio in a separate thread on Android greatly improved the performance of our apps.

Description

I added Media.prototype.playInBackground to the javascript interface. I added the method startPlayingAudioInBackground to both Android and iOS native interfaces.

Testing

The changes are pretty minimal. I installed the plugin in a new cordova project and tested it manually.

adriano-di-giovanni avatar May 31 '19 07:05 adriano-di-giovanni

Can you please add some documentation in README.md about this @adriano-di-giovanni? Thanks.

janpio avatar Jun 19 '19 17:06 janpio

@janpio, done. Thanks.

adriano-di-giovanni avatar Jun 20 '19 07:06 adriano-di-giovanni

CI, please rerun the tests with current configuration.

janpio avatar Jul 04 '19 11:07 janpio

As iOS already runs the play command in a background thread anyway, why not just update Android to have the same behaviour by default? No need to introduce any new functions then and the change is backward compatible with any existing implementation of the plugin.

ghenry22 avatar Jul 19 '20 02:07 ghenry22