Saved the playback position when the player is paused

This commit is contained in:
CappielloAntonio
2022-01-02 17:43:30 +01:00
parent e4d09f3bc0
commit 40866a2855
7 changed files with 101 additions and 13 deletions

View File

@@ -3,6 +3,7 @@ package com.cappielloantonio.play.service;
import android.annotation.SuppressLint;
import android.app.PendingIntent;
import android.content.Intent;
import android.util.Log;
import androidx.annotation.Nullable;
import androidx.media3.common.AudioAttributes;
@@ -18,7 +19,6 @@ import androidx.media3.session.MediaSession;
import com.cappielloantonio.play.ui.activity.MainActivity;
import com.cappielloantonio.play.util.DownloadUtil;
import com.google.android.gms.cast.framework.CastContext;
public class MediaService extends MediaLibraryService {
private static final String TAG = "MediaService";
@@ -98,6 +98,13 @@ public class MediaService extends MediaLibraryService {
public void onMediaItemTransition(@Nullable MediaItem mediaItem, int reason) {
MediaManager.setLastPlayedTimestamp(mediaItem);
}
@Override
public void onIsPlayingChanged(boolean isPlaying) {
if(isPlaying) {
MediaManager.setPlayingChangedTimestamp(player.getCurrentMediaItem(), player.getCurrentPosition());
}
}
});
}
}