mirror of
https://github.com/antebudimir/tempus.git
synced 2025-12-31 17:43:32 +00:00
feat: Mark currently playing song in SongHorizontalAdapter
This commit is contained in:
parent
c62d2ace4d
commit
52ba783a90
10 changed files with 162 additions and 0 deletions
|
|
@ -12,6 +12,7 @@ import androidx.media3.session.SessionToken;
|
|||
|
||||
import com.cappielloantonio.tempo.App;
|
||||
import com.cappielloantonio.tempo.interfaces.MediaIndexCallback;
|
||||
import com.cappielloantonio.tempo.interfaces.MediaSongIdCallback;
|
||||
import com.cappielloantonio.tempo.model.Chronology;
|
||||
import com.cappielloantonio.tempo.repository.ChronologyRepository;
|
||||
import com.cappielloantonio.tempo.repository.QueueRepository;
|
||||
|
|
@ -292,6 +293,25 @@ public class MediaManager {
|
|||
}
|
||||
}
|
||||
|
||||
public static void getCurrentSongId(ListenableFuture<MediaBrowser> mediaBrowserListenableFuture, MediaSongIdCallback callback) {
|
||||
if (mediaBrowserListenableFuture != null) {
|
||||
mediaBrowserListenableFuture.addListener(() -> {
|
||||
try {
|
||||
if (mediaBrowserListenableFuture.isDone()) {
|
||||
MediaItem currentItem = mediaBrowserListenableFuture.get().getCurrentMediaItem();
|
||||
if (currentItem != null) {
|
||||
callback.onRecovery(currentItem.mediaMetadata.extras.getString("id"));
|
||||
} else {
|
||||
callback.onRecovery(null);
|
||||
}
|
||||
}
|
||||
} catch (ExecutionException | InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}, MoreExecutors.directExecutor());
|
||||
}
|
||||
}
|
||||
|
||||
public static void setLastPlayedTimestamp(MediaItem mediaItem) {
|
||||
if (mediaItem != null) getQueueRepository().setLastPlayedTimestamp(mediaItem.mediaId);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue