Merge pull request #3 from KristupasSavickas/android-10-notification-progress-bar-fixes

Fix media progress bar on android 10
This commit is contained in:
dkanada 2020-09-13 01:19:31 +09:00 committed by GitHub
commit 135ff2b8e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -516,7 +516,7 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
mediaSession.setPlaybackState( mediaSession.setPlaybackState(
new PlaybackStateCompat.Builder() new PlaybackStateCompat.Builder()
.setActions(MEDIA_SESSION_ACTIONS) .setActions(MEDIA_SESSION_ACTIONS)
.setState(isPlaying() ? PlaybackStateCompat.STATE_PLAYING : PlaybackStateCompat.STATE_PAUSED, getPosition(), 1) .setState(isPlaying() ? PlaybackStateCompat.STATE_PLAYING : PlaybackStateCompat.STATE_PAUSED, getSongProgressMillis(), 1)
.build()); .build());
} }
@ -983,6 +983,7 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
case META_CHANGED: case META_CHANGED:
updateNotification(); updateNotification();
updateMediaSessionMetaData(); updateMediaSessionMetaData();
updateMediaSessionPlaybackState();
savePosition(); savePosition();
saveProgress(); saveProgress();
break; break;
@ -1099,6 +1100,7 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
if (service.getRepeatMode() == REPEAT_MODE_NONE && service.isLastTrack()) { if (service.getRepeatMode() == REPEAT_MODE_NONE && service.isLastTrack()) {
service.pause(); service.pause();
service.seek(0); service.seek(0);
service.notifyChange(PLAY_STATE_CHANGED);
} else { } else {
service.position = service.nextPosition; service.position = service.nextPosition;
service.prepareNextImpl(); service.prepareNextImpl();
@ -1129,6 +1131,8 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
case PLAY_SONG: case PLAY_SONG:
service.playSongAtImpl(msg.arg1); service.playSongAtImpl(msg.arg1);
// notification progress needs to be reset
service.notifyChange(PLAY_STATE_CHANGED);
break; break;
case SET_POSITION: case SET_POSITION: