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); MusicPlayerRemote.seekTo((int) position);
break; break;
case Stop: case Stop:
MusicPlayerRemote.pauseSong();
MusicPlayerRemote.clearQueue(); MusicPlayerRemote.clearQueue();
} }
} }

View file

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