cordova-plugin-nativeaudio
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)
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?
I have found the same issue (#33): https://github.com/floatinghotpot/cordova-plugin-nativeaudio/issues/33
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.
Maybe you can use https://github.com/katzer/cordova-plugin-background-mode on Android.