@rapropos You’re pretty knowledgable, you got any insights on this one?!
I’m currently building an app that plays audio using the MediaPlayer
in Android (Java). This is all working and I’m not askinf for help with this part at all.
I’ve noticed that the app out of the box:
- still plays my audio when I put my app in the background
- still plays audio when I lock the phone screen.
- never times out (tried with an 18m mp3)
Questions:
-
Is the Android version of the Capacitor bridge effectively already running as a thread or foreground service and that’s how it communicates with JS?
-
So I’m wondering if I need to specifically write a background service to encapsulate my mediaPlayer or not still?
Would really like to understand this before I dive any further.
Just for example, this is a stub of my plugin:
e.g.
@CapacitorPlugin(name = "RemoteAudio")
public class RemoteAudioPlugin extends Plugin {
final MediaPlayer mp = new MediaPlayer();
@PluginMethod
public void play(PluginCall call) {
mp.play();
}
@PluginMethod
public void pause(PluginCall call) {
mp.pause();
}
// etc...
}