diff --git a/android/app/src/main/java/org/musicpd/Bridge.java b/android/app/src/main/java/org/musicpd/Bridge.java index 0ca31ebe6..24b50f87b 100644 --- a/android/app/src/main/java/org/musicpd/Bridge.java +++ b/android/app/src/main/java/org/musicpd/Bridge.java @@ -18,6 +18,7 @@ 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 playPause(); public static native void playNext(); public static native void playPrevious(); } diff --git a/android/app/src/main/java/org/musicpd/MPDPlayer.java b/android/app/src/main/java/org/musicpd/MPDPlayer.java index 3a1d8c087..9e51f3d6c 100644 --- a/android/app/src/main/java/org/musicpd/MPDPlayer.java +++ b/android/app/src/main/java/org/musicpd/MPDPlayer.java @@ -36,7 +36,11 @@ public class MPDPlayer extends SimpleBasePlayer { @NonNull @Override protected State getState() { - Commands commands = new Commands.Builder().addAll(COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM, COMMAND_SEEK_TO_NEXT_MEDIA_ITEM).build(); + Commands commands = new Commands.Builder().addAll( + COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM, + COMMAND_SEEK_TO_NEXT_MEDIA_ITEM, + COMMAND_PLAY_PAUSE + ).build(); return new State.Builder() .setAvailableCommands(commands) @@ -46,6 +50,13 @@ public class MPDPlayer extends SimpleBasePlayer { .build(); } + @NonNull + @Override + protected ListenableFuture handleSetPlayWhenReady(boolean playWhenReady) { + Bridge.playPause(); + return Futures.immediateVoidFuture(); + } + @NonNull @SuppressLint("SwitchIntDef") @Override diff --git a/src/Main.cxx b/src/Main.cxx index 6b10ff6d4..bab9da76a 100644 --- a/src/Main.cxx +++ b/src/Main.cxx @@ -614,6 +614,16 @@ Java_org_musicpd_Bridge_pause(JNIEnv *, jclass) partition.pc.LockSetPause(true); } +gcc_visibility_default +JNIEXPORT void JNICALL +Java_org_musicpd_Bridge_playPause(JNIEnv *, jclass) +{ + if (global_instance != nullptr) + for (auto &partition : global_instance->partitions) + partition.pc.LockPause(); + +} + gcc_visibility_default JNIEXPORT void JNICALL Java_org_musicpd_Bridge_playNext(JNIEnv *, jclass)