android: Check playlist state before changing track

Playlist will throw an exception if we call next or previous track when it is not in the "playing" state
This commit is contained in:
Colin Edwards 2024-01-13 23:19:31 -06:00
parent 380e0abbe4
commit 0075c57bd4
1 changed files with 6 additions and 2 deletions

View File

@ -621,7 +621,9 @@ Java_org_musicpd_Bridge_playNext(JNIEnv *, jclass)
if (global_instance != nullptr)
BlockingCall(global_instance->event_loop, [&](){
for (auto &partition : global_instance->partitions)
partition.PlayNext();
if (partition.playlist.playing) {
partition.PlayNext();
}
});
}
@ -632,7 +634,9 @@ Java_org_musicpd_Bridge_playPrevious(JNIEnv *, jclass)
if (global_instance != nullptr)
BlockingCall(global_instance->event_loop, [&](){
for (auto &partition : global_instance->partitions)
partition.PlayPrevious();
if (partition.playlist.playing) {
partition.PlayPrevious();
}
});
}