Do not expand player when queue is restored (#396)

This commit is contained in:
vfsfitvnm 2022-10-10 11:48:58 +02:00
parent ff611d792e
commit fae96d1114
3 changed files with 11 additions and 5 deletions

View file

@ -359,9 +359,9 @@ class MainActivity : ComponentActivity() {
if (playerBottomSheetState.isDismissed) { if (playerBottomSheetState.isDismissed) {
if (launchedFromNotification) { if (launchedFromNotification) {
intent.replaceExtras(Bundle()) intent.replaceExtras(Bundle())
playerBottomSheetState.expandSoft() playerBottomSheetState.expand(tween(700))
} else { } else {
playerBottomSheetState.collapseSoft() playerBottomSheetState.collapse(tween(700))
} }
} }
} }
@ -369,7 +369,11 @@ class MainActivity : ComponentActivity() {
player.listener(object : Player.Listener { player.listener(object : Player.Listener {
override fun onMediaItemTransition(mediaItem: MediaItem?, reason: Int) { override fun onMediaItemTransition(mediaItem: MediaItem?, reason: Int) {
if (reason == Player.MEDIA_ITEM_TRANSITION_REASON_PLAYLIST_CHANGED && mediaItem != null) { if (reason == Player.MEDIA_ITEM_TRANSITION_REASON_PLAYLIST_CHANGED && mediaItem != null) {
if (mediaItem.mediaMetadata.extras?.getBoolean("isFromPersistentQueue") != true) {
playerBottomSheetState.expand(tween(500)) playerBottomSheetState.expand(tween(500))
} else {
playerBottomSheetState.collapse(tween(700))
}
} }
} }
}) })

View file

@ -377,7 +377,9 @@ class PlayerService : InvincibleService(), Player.Listener, PlaybackStatsListene
mediaItem.mediaItem.buildUpon() mediaItem.mediaItem.buildUpon()
.setUri(mediaItem.mediaItem.mediaId) .setUri(mediaItem.mediaItem.mediaId)
.setCustomCacheKey(mediaItem.mediaItem.mediaId) .setCustomCacheKey(mediaItem.mediaItem.mediaId)
.build() .build().apply {
mediaMetadata.extras?.putBoolean("isFromPersistentQueue", true)
}
}, },
index, index,
queuedSong[index].position ?: C.TIME_UNSET queuedSong[index].position ?: C.TIME_UNSET

View file

@ -129,7 +129,7 @@ class BottomSheetState(
1f - (animatable.upperBound!! - animatable.value) / (animatable.upperBound!! - collapsedBound) 1f - (animatable.upperBound!! - animatable.value) / (animatable.upperBound!! - collapsedBound)
} }
private fun collapse(animationSpec: AnimationSpec<Dp>) { fun collapse(animationSpec: AnimationSpec<Dp>) {
onAnchorChanged(collapsedAnchor) onAnchorChanged(collapsedAnchor)
coroutineScope.launch { coroutineScope.launch {
animatable.animateTo(collapsedBound, animationSpec) animatable.animateTo(collapsedBound, animationSpec)