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

Ability to keep playing sound when app is inactive (e.g. when the screen is turned off, or the user switches to another app)

Open eworker2003 opened this issue 9 years ago • 3 comments

Very good plugin! Thanks!

Is it possible to keep playing sound when app is inactive (e.g. when the screen is turned off, or the user switches to another app)? Now when I turn screen off (or lock screen) the audio playing is stopped.

I tried to use Media plugin for looping mp3-audio file which length is about 60 seconds. But the Media plugin interrupts sound on ~50 second in Sony Z3 (Android 5.x) when screen is turned off (or locked), so the full mp3 audio file cannot be played. Media plugin works fine on Nexus 7 (Android 4.x) even app is inactive or screen is turned off.

Native Audio Plugin play sound ONLY when app is active. Any ideas how to don't stop play sound when screen if turned off?

eworker2003 avatar Dec 27 '15 19:12 eworker2003

I have found the same issue (#33): https://github.com/floatinghotpot/cordova-plugin-nativeaudio/issues/33

eworker2003 avatar Dec 27 '15 20:12 eworker2003

I have changed the original code of plugin - not call super.onPause(): public void onPause(boolean multitasking) { } It is helped to play sound even screen is locked or turned off.

But it is not fix the problem with playing audio on Sony X3 (Android 5.x)! :( I have the same problem as using Media plugin - the audio is stopped on ~54 second.

eworker2003 avatar Jan 01 '16 20:01 eworker2003

Maybe you can use https://github.com/katzer/cordova-plugin-background-mode on Android.

Heshyo avatar May 17 '16 02:05 Heshyo