mirror of
https://github.com/antebudimir/tempus.git
synced 2026-04-15 16:27:26 +00:00
fix: use existing future when adding tracks, dialed random album trac… (#373)
fix: use existing future when adding tracks, dialed random album tracks back to 100, vs 1000.
This commit is contained in:
parent
72b1517f61
commit
023bd8071a
3 changed files with 15 additions and 14 deletions
|
|
@ -4,6 +4,7 @@ import android.annotation.SuppressLint
|
||||||
import android.app.PendingIntent.FLAG_IMMUTABLE
|
import android.app.PendingIntent.FLAG_IMMUTABLE
|
||||||
import android.app.PendingIntent.FLAG_UPDATE_CURRENT
|
import android.app.PendingIntent.FLAG_UPDATE_CURRENT
|
||||||
import android.app.TaskStackBuilder
|
import android.app.TaskStackBuilder
|
||||||
|
import android.content.ComponentName
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.net.ConnectivityManager
|
import android.net.ConnectivityManager
|
||||||
|
|
@ -138,8 +139,13 @@ open class BaseMediaService : MediaLibraryService() {
|
||||||
if (item.mediaMetadata.extras != null)
|
if (item.mediaMetadata.extras != null)
|
||||||
MediaManager.scrobble(item, false)
|
MediaManager.scrobble(item, false)
|
||||||
|
|
||||||
if (player.nextMediaItemIndex == C.INDEX_UNSET)
|
if (player.nextMediaItemIndex == C.INDEX_UNSET) {
|
||||||
MediaManager.continuousPlay(player.currentMediaItem)
|
val browserFuture = MediaBrowser.Builder(
|
||||||
|
this@BaseMediaService,
|
||||||
|
SessionToken(this@BaseMediaService, ComponentName(this@BaseMediaService, this@BaseMediaService::class.java))
|
||||||
|
).buildAsync()
|
||||||
|
MediaManager.continuousPlay(player.currentMediaItem, browserFuture)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player is ExoPlayer) {
|
if (player is ExoPlayer) {
|
||||||
|
|
|
||||||
|
|
@ -444,7 +444,7 @@ public class MediaManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(markerClass = UnstableApi.class)
|
@OptIn(markerClass = UnstableApi.class)
|
||||||
public static void continuousPlay(MediaItem mediaItem) {
|
public static void continuousPlay(MediaItem mediaItem, ListenableFuture<MediaBrowser> existingBrowserFuture) {
|
||||||
if (mediaItem != null && Preferences.isContinuousPlayEnabled() && Preferences.isInstantMixUsable()) {
|
if (mediaItem != null && Preferences.isContinuousPlayEnabled() && Preferences.isInstantMixUsable()) {
|
||||||
Preferences.setLastInstantMix();
|
Preferences.setLastInstantMix();
|
||||||
|
|
||||||
|
|
@ -453,14 +453,9 @@ public class MediaManager {
|
||||||
instantMix.observeForever(new Observer<List<Child>>() {
|
instantMix.observeForever(new Observer<List<Child>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(List<Child> media) {
|
public void onChanged(List<Child> media) {
|
||||||
if (media != null) {
|
if (media != null && existingBrowserFuture != null) {
|
||||||
Log.e(TAG, "continuous play");
|
Log.d(TAG, "Continuous play: adding " + media.size() + " tracks");
|
||||||
ListenableFuture<MediaBrowser> mediaBrowserListenableFuture = new MediaBrowser.Builder(
|
enqueue(existingBrowserFuture, media, false);
|
||||||
App.getContext(),
|
|
||||||
new SessionToken(App.getContext(), new ComponentName(App.getContext(), MediaService.class))
|
|
||||||
).buildAsync();
|
|
||||||
|
|
||||||
enqueue(mediaBrowserListenableFuture, media, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
instantMix.removeObserver(this);
|
instantMix.removeObserver(this);
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ public class HomeViewModel extends AndroidViewModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<List<Child>> getRandomShuffleSample() {
|
public LiveData<List<Child>> getRandomShuffleSample() {
|
||||||
return songRepository.getRandomSample(1000, null, null);
|
return songRepository.getRandomSample(100, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<List<Chronology>> getChronologySample(LifecycleOwner owner) {
|
public LiveData<List<Chronology>> getChronologySample(LifecycleOwner owner) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue