android: add next and previous track to the jni bridge

This will allow the android client to directly make calls to the mpd process to change tracks

I went with camel case on the function names here, if you use an underscore
javac generates a function tht looks like this:
 JNIEXPORT void JNICALL Java_org_musicpd_Bridge_play_1previous

I figured what we ended up with looks a little nicer:
JNIEXPORT void JNICALL Java_org_musicpd_Bridge_playPrevious
This commit is contained in:
Colin Edwards 2023-12-28 22:46:59 -06:00
parent 468eceabff
commit e086f09d48
2 changed files with 24 additions and 0 deletions

View File

@ -18,4 +18,6 @@ public class Bridge {
public static native void run(Context context, LogListener logListener);
public static native void shutdown();
public static native void pause();
public static native void playNext();
public static native void playPrevious();
}

View File

@ -614,6 +614,28 @@ Java_org_musicpd_Bridge_pause(JNIEnv *, jclass)
partition.pc.LockSetPause(true);
}
gcc_visibility_default
JNIEXPORT void JNICALL
Java_org_musicpd_Bridge_playNext(JNIEnv *, jclass)
{
if (global_instance != nullptr)
BlockingCall(global_instance->event_loop, [&](){
for (auto &partition : global_instance->partitions)
partition.PlayNext();
});
}
gcc_visibility_default
JNIEXPORT void JNICALL
Java_org_musicpd_Bridge_playPrevious(JNIEnv *, jclass)
{
if (global_instance != nullptr)
BlockingCall(global_instance->event_loop, [&](){
for (auto &partition : global_instance->partitions)
partition.PlayPrevious();
});
}
#else
static inline void