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(
new PlaybackStateCompat.Builder()
.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());
}
@ -983,6 +983,7 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
case META_CHANGED:
updateNotification();
updateMediaSessionMetaData();
updateMediaSessionPlaybackState();
savePosition();
saveProgress();
break;
@ -1099,6 +1100,7 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
if (service.getRepeatMode() == REPEAT_MODE_NONE && service.isLastTrack()) {
service.pause();
service.seek(0);
service.notifyChange(PLAY_STATE_CHANGED);
} else {
service.position = service.nextPosition;
service.prepareNextImpl();
@ -1129,6 +1131,8 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
case PLAY_SONG:
service.playSongAtImpl(msg.arg1);
// notification progress needs to be reset
service.notifyChange(PLAY_STATE_CHANGED);
break;
case SET_POSITION: