fix issues with notification when queue is cleared

This commit is contained in:
dkanada 2021-04-17 13:19:00 +09:00
commit bc92f9a22c
2 changed files with 5 additions and 5 deletions

View file

@ -80,7 +80,6 @@ public class EventListener extends ApiEventListener {
MusicPlayerRemote.seekTo((int) position);
break;
case Stop:
MusicPlayerRemote.pauseSong();
MusicPlayerRemote.clearQueue();
}
}

View file

@ -513,8 +513,8 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
private void openCurrent() {
synchronized (this) {
// current song will be null when queue is cleared
if (getCurrentSong() == null) return;
// current song title will be null when queue is cleared
if (getCurrentSong().title == null) return;
playback.setDataSource(getCurrentSong());
}
@ -547,7 +547,7 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
}
public void updateNotification() {
if (playingNotification != null && getCurrentSong().id != null) {
if (playingNotification != null && getCurrentSong().title != null) {
playingNotification.update();
}
}
@ -564,7 +564,7 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
private void updateMediaSessionMetadata() {
final Song song = getCurrentSong();
if (song.id == null) {
if (song.title == null) {
mediaSession.setMetadata(null);
return;
}
@ -1002,6 +1002,7 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
if (playingQueue.size() > 0) {
prepareNext();
} else {
playback.pause();
playingNotification.stop();
}
break;