android: Support play / pause from media session
This commit is contained in:
parent
380e0abbe4
commit
87873c9a73
|
@ -18,6 +18,7 @@ public class Bridge {
|
||||||
public static native void run(Context context, LogListener logListener);
|
public static native void run(Context context, LogListener logListener);
|
||||||
public static native void shutdown();
|
public static native void shutdown();
|
||||||
public static native void pause();
|
public static native void pause();
|
||||||
|
public static native void playPause();
|
||||||
public static native void playNext();
|
public static native void playNext();
|
||||||
public static native void playPrevious();
|
public static native void playPrevious();
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,11 @@ public class MPDPlayer extends SimpleBasePlayer {
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
protected State getState() {
|
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()
|
return new State.Builder()
|
||||||
.setAvailableCommands(commands)
|
.setAvailableCommands(commands)
|
||||||
|
@ -46,6 +50,13 @@ public class MPDPlayer extends SimpleBasePlayer {
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
protected ListenableFuture<?> handleSetPlayWhenReady(boolean playWhenReady) {
|
||||||
|
Bridge.playPause();
|
||||||
|
return Futures.immediateVoidFuture();
|
||||||
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@SuppressLint("SwitchIntDef")
|
@SuppressLint("SwitchIntDef")
|
||||||
@Override
|
@Override
|
||||||
|
|
10
src/Main.cxx
10
src/Main.cxx
|
@ -614,6 +614,16 @@ Java_org_musicpd_Bridge_pause(JNIEnv *, jclass)
|
||||||
partition.pc.LockSetPause(true);
|
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
|
gcc_visibility_default
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
Java_org_musicpd_Bridge_playNext(JNIEnv *, jclass)
|
Java_org_musicpd_Bridge_playNext(JNIEnv *, jclass)
|
||||||
|
|
Loading…
Reference in New Issue