Skip to content

Commit

Permalink
* Fix link to Artist's Page
Browse files Browse the repository at this point in the history
  • Loading branch information
fast4x committed Oct 8, 2023
1 parent 01e7600 commit 74241bc
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.dp
import androidx.media3.common.MediaItem
import androidx.media3.common.util.Log
import it.vfsfitvnm.innertube.models.NavigationEndpoint
import it.vfsfitvnm.vimusic.Database
import it.vfsfitvnm.vimusic.LocalPlayerServiceBinder
Expand Down Expand Up @@ -683,7 +684,7 @@ fun MediaItemMenu(
artistsInfo?.forEach { (authorId, authorName) ->
MenuEntry(
icon = R.drawable.person,
text = stringResource(R.string.more_of) + " $authorName ",
text = stringResource(R.string.more_of) + " $authorName -> $authorId",
onClick = {
onDismiss()
onGoToArtist(authorId)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package it.vfsfitvnm.vimusic.ui.screens.player

import android.util.Log
import androidx.compose.animation.animateContentSize
import androidx.compose.animation.core.LinearEasing
import androidx.compose.animation.core.animateDp
import androidx.compose.animation.core.tween
Expand Down Expand Up @@ -56,7 +57,15 @@ import it.vfsfitvnm.vimusic.utils.semiBold
import it.vfsfitvnm.vimusic.utils.trackLoopEnabledKey
import kotlinx.coroutines.flow.distinctUntilChanged
import androidx.compose.foundation.text.ClickableText
import androidx.compose.ui.draw.blur
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.semantics.Role.Companion.Button
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.withStyle
import it.vfsfitvnm.compose.reordering.animateItemPlacement
import it.vfsfitvnm.vimusic.models.Info
import it.vfsfitvnm.vimusic.ui.screens.artistRoute

@OptIn(ExperimentalFoundationApi::class)
Expand Down Expand Up @@ -100,8 +109,9 @@ fun Controls(
targetValueByState = { if (it) 32.dp else 16.dp }
)


Column(
horizontalAlignment = Alignment.CenterHorizontally,
horizontalAlignment = Alignment.Start,
modifier = modifier
.fillMaxWidth()
.padding(horizontal = 32.dp)
Expand All @@ -113,7 +123,7 @@ fun Controls(
)
*/
BasicText(
text = title ?: "",
text = "Title: " + title ?: "",
style = typography.l.bold,
maxLines = 1,
overflow = TextOverflow.Ellipsis
Expand All @@ -126,20 +136,20 @@ fun Controls(

ClickableText(
text = AnnotatedString(artist ?: ""),
style = typography.s.bold,
style = typography.l.secondary,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
onClick = {
if (artistIds?.size==1)
//Log.d("ClickArtist","id Artista ${artistIds[0].toString()}")
//Log.d("ClickArtist","id Artist ${artistIds[0].toString()}")
onGoToArtist(artistIds?.get(0).toString())
//else Log.d("ClickArtist","More than 1 artist")
}
)

Spacer(
modifier = Modifier
.weight(1f)
.weight(2f)
)

SeekBar(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.media3.common.MediaItem
import androidx.media3.common.Player
import androidx.media3.common.util.Log
import coil.compose.AsyncImage
import it.vfsfitvnm.innertube.models.NavigationEndpoint
import it.vfsfitvnm.compose.routing.OnGlobalRoute
Expand Down Expand Up @@ -89,6 +90,8 @@ fun Player(
layoutState: BottomSheetState,
modifier: Modifier = Modifier,
) {
val context = LocalContext.current

val menuState = LocalMenuState.current

val (colorPalette, typography, thumbnailShape) = LocalAppearance.current
Expand All @@ -104,6 +107,7 @@ fun Player(
mutableStateOf(binder.player.shouldBePlaying)
}


binder.player.DisposableListener {
object : Player.Listener {
override fun onMediaItemTransition(mediaItem: MediaItem?, reason: Int) {
Expand All @@ -129,6 +133,51 @@ fun Player(
val horizontalBottomPaddingValues = windowInsets
.only(WindowInsetsSides.Horizontal + WindowInsetsSides.Bottom).asPaddingValues()

var albumInfo by remember {
mutableStateOf(mediaItem.mediaMetadata.extras?.getString("albumId")?.let { albumId ->
Info(albumId, null)
})
}

var artistsInfo by remember {
mutableStateOf(
mediaItem.mediaMetadata.extras?.getStringArrayList("artistNames")?.let { artistNames ->
mediaItem.mediaMetadata.extras?.getStringArrayList("artistIds")?.let { artistIds ->
artistNames.zip(artistIds).map { (authorName, authorId) ->
Info(authorId, authorName)
}
}
}
)
}

LaunchedEffect(mediaItem.mediaId) {
withContext(Dispatchers.IO) {
//if (albumInfo == null)
albumInfo = Database.songAlbumInfo(mediaItem.mediaId)
//if (artistsInfo == null)
artistsInfo = Database.songArtistInfo(mediaItem.mediaId)
}
}

var artistIds = arrayListOf<String>()
//var albumIds = arrayListOf<String>()
//val ExistIdsExtras = mediaItem.mediaMetadata.extras?.getStringArrayList("artistIds")?.size.toString()

artistsInfo?.forEach { (id) -> artistIds = arrayListOf(id) }
if (artistsInfo == null) mediaItem.mediaMetadata.extras?.getStringArray("artistIds")?.toCollection(artistIds)

/* TODO Album name */
// albumInfo?.forEach { (id) -> albumIds = arrayListOf(id) }
// if (albumInfo == null) mediaItem.mediaMetadata.extras?.getStringArray("artistIds")?.toCollection(albumIds)

//Log.d("mediaItem_play_mediaId",mediaItem.mediaId)
//Log.d("mediaItem_play_extra?",ExistIdsExtras.toString())
//Log.d("mediaItem_play_extras",mediaItem.mediaMetadata.extras.toString())
//Log.d("mediaItem_play_artinfo",artistsInfo.toString())
//Log.d("mediaItem_play_artid",artistIds.toString())
//Log.d("mediaItem_play_albinfo",albumInfo.toString())

OnGlobalRoute {
layoutState.collapseSoft()
}
Expand Down Expand Up @@ -286,10 +335,7 @@ fun Player(
mediaId = mediaItem.mediaId,
title = mediaItem.mediaMetadata.title?.toString(),
artist = mediaItem.mediaMetadata.artist?.toString(),
//artistId = mediaItem.mediaMetadata.extras.toString(),
artistIds = mediaItem.mediaMetadata.extras?.getStringArrayList("artistIds"),

//artistId = "x34222",
artistIds = artistIds,
shouldBePlaying = shouldBePlaying,
position = positionAndDuration.first,
duration = positionAndDuration.second,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,18 @@ fun Queue(
.align(Alignment.CenterEnd)
.animateContentSize()
) {
BasicText(
/* BasicText(
text = stringResource(R.string.queue_loop),
style = typography.xxs.medium,
)*/
Image(
painter = painterResource(R.drawable.infinite),
contentDescription = null,
colorFilter = ColorFilter.tint(colorPalette.text),
modifier = Modifier
//.align(Alignment.Center)
.size(18.dp)

)

AnimatedContent(
Expand All @@ -386,7 +395,7 @@ fun Queue(
}
) {
BasicText(
text = if (it) "on" else "off",
text = if (it) " on" else " off",
style = typography.xxs.medium,
)
}
Expand Down

0 comments on commit 74241bc

Please sign in to comment.