Drop androidx.media3
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package it.vfsfitvnm.vimusic.ui.screens
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.compose.animation.ExperimentalAnimationApi
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.background
|
||||
@@ -27,10 +26,9 @@ import coil.compose.AsyncImage
|
||||
import com.valentinilk.shimmer.shimmer
|
||||
import it.vfsfitvnm.route.RouteHandler
|
||||
import it.vfsfitvnm.vimusic.Database
|
||||
import it.vfsfitvnm.vimusic.LocalPlayerServiceBinder
|
||||
import it.vfsfitvnm.vimusic.R
|
||||
import it.vfsfitvnm.vimusic.models.SongWithInfo
|
||||
import it.vfsfitvnm.vimusic.services.StartArtistRadioCommand
|
||||
import it.vfsfitvnm.vimusic.services.StopRadioCommand
|
||||
import it.vfsfitvnm.vimusic.ui.components.OutcomeItem
|
||||
import it.vfsfitvnm.vimusic.ui.components.TopAppBar
|
||||
import it.vfsfitvnm.vimusic.ui.components.themed.InHistoryMediaItemMenu
|
||||
@@ -79,7 +77,8 @@ fun ArtistScreen(
|
||||
}
|
||||
|
||||
host {
|
||||
val player = LocalYoutubePlayer.current
|
||||
val binder = LocalPlayerServiceBinder.current
|
||||
|
||||
val density = LocalDensity.current
|
||||
val colorPalette = LocalColorPalette.current
|
||||
val typography = LocalTypography.current
|
||||
@@ -160,10 +159,7 @@ fun ArtistScreen(
|
||||
colorFilter = ColorFilter.tint(colorPalette.text),
|
||||
modifier = Modifier
|
||||
.clickable {
|
||||
player?.mediaController?.sendCustomCommand(
|
||||
StartArtistRadioCommand,
|
||||
artist.shuffleEndpoint.asBundle
|
||||
)
|
||||
binder?.startRadio(artist.shuffleEndpoint)
|
||||
}
|
||||
.shadow(elevation = 2.dp, shape = CircleShape)
|
||||
.background(
|
||||
@@ -180,10 +176,7 @@ fun ArtistScreen(
|
||||
colorFilter = ColorFilter.tint(colorPalette.text),
|
||||
modifier = Modifier
|
||||
.clickable {
|
||||
player?.mediaController?.sendCustomCommand(
|
||||
StartArtistRadioCommand,
|
||||
artist.radioEndpoint.asBundle
|
||||
)
|
||||
binder?.startRadio(artist.radioEndpoint)
|
||||
}
|
||||
.shadow(elevation = 2.dp, shape = CircleShape)
|
||||
.background(
|
||||
@@ -224,14 +217,8 @@ fun ArtistScreen(
|
||||
colorFilter = ColorFilter.tint(colorPalette.text),
|
||||
modifier = Modifier
|
||||
.clickable(enabled = songs.isNotEmpty()) {
|
||||
player?.mediaController?.let {
|
||||
it.sendCustomCommand(StopRadioCommand, Bundle.EMPTY)
|
||||
it.forcePlayFromBeginning(
|
||||
songs
|
||||
.shuffled()
|
||||
.map(SongWithInfo::asMediaItem)
|
||||
)
|
||||
}
|
||||
binder?.stopRadio()
|
||||
binder?.player?.forcePlayFromBeginning(songs.shuffled().map(SongWithInfo::asMediaItem))
|
||||
}
|
||||
.padding(horizontal = 8.dp, vertical = 8.dp)
|
||||
.size(20.dp)
|
||||
@@ -248,10 +235,8 @@ fun ArtistScreen(
|
||||
song = song,
|
||||
thumbnailSize = songThumbnailSizePx,
|
||||
onClick = {
|
||||
player?.mediaController?.let {
|
||||
it.sendCustomCommand(StopRadioCommand, Bundle.EMPTY)
|
||||
it.forcePlayAtIndex(songs.map(SongWithInfo::asMediaItem), index)
|
||||
}
|
||||
binder?.stopRadio()
|
||||
binder?.player?.forcePlayAtIndex(songs.map(SongWithInfo::asMediaItem), index)
|
||||
},
|
||||
menuContent = {
|
||||
InHistoryMediaItemMenu(song = song)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package it.vfsfitvnm.vimusic.ui.screens
|
||||
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import androidx.compose.animation.*
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.Image
|
||||
@@ -32,15 +31,18 @@ import androidx.compose.ui.zIndex
|
||||
import it.vfsfitvnm.route.RouteHandler
|
||||
import it.vfsfitvnm.route.fastFade
|
||||
import it.vfsfitvnm.vimusic.Database
|
||||
import it.vfsfitvnm.vimusic.LocalPlayerServiceBinder
|
||||
import it.vfsfitvnm.vimusic.R
|
||||
import it.vfsfitvnm.vimusic.enums.SongCollection
|
||||
import it.vfsfitvnm.vimusic.enums.ThumbnailRoundness
|
||||
import it.vfsfitvnm.vimusic.models.Playlist
|
||||
import it.vfsfitvnm.vimusic.models.SearchQuery
|
||||
import it.vfsfitvnm.vimusic.models.SongWithInfo
|
||||
import it.vfsfitvnm.vimusic.services.StopRadioCommand
|
||||
import it.vfsfitvnm.vimusic.ui.components.TopAppBar
|
||||
import it.vfsfitvnm.vimusic.ui.components.themed.*
|
||||
import it.vfsfitvnm.vimusic.ui.components.themed.InFavoritesMediaItemMenu
|
||||
import it.vfsfitvnm.vimusic.ui.components.themed.InHistoryMediaItemMenu
|
||||
import it.vfsfitvnm.vimusic.ui.components.themed.NonQueuedMediaItemMenu
|
||||
import it.vfsfitvnm.vimusic.ui.components.themed.TextFieldDialog
|
||||
import it.vfsfitvnm.vimusic.ui.styling.LocalColorPalette
|
||||
import it.vfsfitvnm.vimusic.ui.styling.LocalTypography
|
||||
import it.vfsfitvnm.vimusic.ui.views.PlaylistPreviewItem
|
||||
@@ -144,7 +146,7 @@ fun HomeScreen() {
|
||||
}
|
||||
|
||||
host {
|
||||
val player = LocalYoutubePlayer.current
|
||||
val binder = LocalPlayerServiceBinder.current
|
||||
val density = LocalDensity.current
|
||||
|
||||
val thumbnailSize = remember {
|
||||
@@ -357,10 +359,8 @@ fun HomeScreen() {
|
||||
colorFilter = ColorFilter.tint(colorPalette.text),
|
||||
modifier = Modifier
|
||||
.clickable(enabled = songCollection.isNotEmpty()) {
|
||||
player?.mediaController?.let {
|
||||
it.sendCustomCommand(StopRadioCommand, Bundle.EMPTY)
|
||||
it.forcePlayFromBeginning(songCollection.shuffled().map(SongWithInfo::asMediaItem))
|
||||
}
|
||||
binder?.stopRadio()
|
||||
binder?.player?.forcePlayFromBeginning(songCollection.shuffled().map(SongWithInfo::asMediaItem))
|
||||
}
|
||||
.padding(horizontal = 8.dp, vertical = 8.dp)
|
||||
.size(20.dp)
|
||||
@@ -379,10 +379,8 @@ fun HomeScreen() {
|
||||
song = song,
|
||||
thumbnailSize = thumbnailSize,
|
||||
onClick = {
|
||||
player?.mediaController?.let {
|
||||
it.sendCustomCommand(StopRadioCommand, Bundle.EMPTY)
|
||||
it.forcePlayAtIndex(songCollection.map(SongWithInfo::asMediaItem), index)
|
||||
}
|
||||
binder?.stopRadio()
|
||||
binder?.player?.forcePlayAtIndex(songCollection.map(SongWithInfo::asMediaItem), index)
|
||||
},
|
||||
menuContent = {
|
||||
when (preferences.homePageSongCollection) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package it.vfsfitvnm.vimusic.ui.screens
|
||||
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import androidx.compose.animation.ExperimentalAnimationApi
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.background
|
||||
@@ -18,16 +17,15 @@ import androidx.compose.ui.graphics.ColorFilter
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.media3.common.Player
|
||||
import com.valentinilk.shimmer.ShimmerBounds
|
||||
import com.valentinilk.shimmer.rememberShimmer
|
||||
import it.vfsfitvnm.route.RouteHandler
|
||||
import it.vfsfitvnm.vimusic.Database
|
||||
import it.vfsfitvnm.vimusic.LocalPlayerServiceBinder
|
||||
import it.vfsfitvnm.vimusic.R
|
||||
import it.vfsfitvnm.vimusic.internal
|
||||
import it.vfsfitvnm.vimusic.models.Playlist
|
||||
import it.vfsfitvnm.vimusic.models.SongInPlaylist
|
||||
import it.vfsfitvnm.vimusic.services.StopRadioCommand
|
||||
import it.vfsfitvnm.vimusic.ui.components.Error
|
||||
import it.vfsfitvnm.vimusic.ui.components.LocalMenuState
|
||||
import it.vfsfitvnm.vimusic.ui.components.Message
|
||||
@@ -70,7 +68,7 @@ fun IntentUriScreen(uri: Uri) {
|
||||
val menuState = LocalMenuState.current
|
||||
val colorPalette = LocalColorPalette.current
|
||||
val density = LocalDensity.current
|
||||
val player = LocalYoutubePlayer.current
|
||||
val binder = LocalPlayerServiceBinder.current
|
||||
|
||||
val coroutineScope = rememberCoroutineScope()
|
||||
val shimmer = rememberShimmer(shimmerBounds = ShimmerBounds.Window)
|
||||
@@ -164,14 +162,13 @@ fun IntentUriScreen(uri: Uri) {
|
||||
MenuEntry(
|
||||
icon = R.drawable.time,
|
||||
text = "Enqueue",
|
||||
enabled = player?.playbackState == Player.STATE_READY,
|
||||
onClick = {
|
||||
menuState.hide()
|
||||
|
||||
items.valueOrNull
|
||||
?.map(YouTube.Item.Song::asMediaItem)
|
||||
?.let { mediaItems ->
|
||||
player?.mediaController?.enqueue(
|
||||
binder?.player?.enqueue(
|
||||
mediaItems
|
||||
)
|
||||
}
|
||||
@@ -238,10 +235,8 @@ fun IntentUriScreen(uri: Uri) {
|
||||
song = item,
|
||||
thumbnailSizePx = density.run { 54.dp.roundToPx() },
|
||||
onClick = {
|
||||
player?.mediaController?.let {
|
||||
it.sendCustomCommand(StopRadioCommand, Bundle.EMPTY)
|
||||
it.forcePlayAtIndex(currentItems.value.map(YouTube.Item.Song::asMediaItem), index)
|
||||
}
|
||||
binder?.stopRadio()
|
||||
binder?.player?.forcePlayAtIndex(currentItems.value.map(YouTube.Item.Song::asMediaItem), index)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package it.vfsfitvnm.vimusic.ui.screens
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.compose.animation.ExperimentalAnimationApi
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.background
|
||||
@@ -22,16 +21,15 @@ import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.platform.LocalHapticFeedback
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.media3.common.Player
|
||||
import it.vfsfitvnm.reordering.rememberReorderingState
|
||||
import it.vfsfitvnm.reordering.verticalDragAfterLongPressToReorder
|
||||
import it.vfsfitvnm.route.RouteHandler
|
||||
import it.vfsfitvnm.vimusic.Database
|
||||
import it.vfsfitvnm.vimusic.LocalPlayerServiceBinder
|
||||
import it.vfsfitvnm.vimusic.R
|
||||
import it.vfsfitvnm.vimusic.models.PlaylistWithSongs
|
||||
import it.vfsfitvnm.vimusic.models.SongInPlaylist
|
||||
import it.vfsfitvnm.vimusic.models.SongWithInfo
|
||||
import it.vfsfitvnm.vimusic.services.StopRadioCommand
|
||||
import it.vfsfitvnm.vimusic.ui.components.LocalMenuState
|
||||
import it.vfsfitvnm.vimusic.ui.components.TopAppBar
|
||||
import it.vfsfitvnm.vimusic.ui.components.themed.*
|
||||
@@ -76,7 +74,7 @@ fun LocalPlaylistScreen(
|
||||
val hapticFeedback = LocalHapticFeedback.current
|
||||
val menuState = LocalMenuState.current
|
||||
|
||||
val player = LocalYoutubePlayer.current
|
||||
val binder = LocalPlayerServiceBinder.current
|
||||
val colorPalette = LocalColorPalette.current
|
||||
val typography = LocalTypography.current
|
||||
|
||||
@@ -163,14 +161,10 @@ fun LocalPlaylistScreen(
|
||||
MenuEntry(
|
||||
icon = R.drawable.time,
|
||||
text = "Enqueue",
|
||||
enabled = playlistWithSongs.songs.isNotEmpty() && player?.playbackState == Player.STATE_READY,
|
||||
enabled = playlistWithSongs.songs.isNotEmpty(),
|
||||
onClick = {
|
||||
menuState.hide()
|
||||
player?.mediaController?.enqueue(
|
||||
playlistWithSongs.songs.map(
|
||||
SongWithInfo::asMediaItem
|
||||
)
|
||||
)
|
||||
binder?.player?.enqueue(playlistWithSongs.songs.map(SongWithInfo::asMediaItem))
|
||||
}
|
||||
)
|
||||
|
||||
@@ -234,10 +228,8 @@ fun LocalPlaylistScreen(
|
||||
colorFilter = ColorFilter.tint(colorPalette.text),
|
||||
modifier = Modifier
|
||||
.clickable {
|
||||
player?.mediaController?.let {
|
||||
it.sendCustomCommand(StopRadioCommand, Bundle.EMPTY)
|
||||
it.forcePlayFromBeginning(playlistWithSongs.songs.map(SongWithInfo::asMediaItem).shuffled())
|
||||
}
|
||||
binder?.stopRadio()
|
||||
binder?.player?.forcePlayFromBeginning(playlistWithSongs.songs.map(SongWithInfo::asMediaItem).shuffled())
|
||||
}
|
||||
.shadow(elevation = 2.dp, shape = CircleShape)
|
||||
.background(
|
||||
@@ -254,10 +246,8 @@ fun LocalPlaylistScreen(
|
||||
colorFilter = ColorFilter.tint(colorPalette.text),
|
||||
modifier = Modifier
|
||||
.clickable {
|
||||
player?.mediaController?.let {
|
||||
it.sendCustomCommand(StopRadioCommand, Bundle.EMPTY)
|
||||
it.forcePlayFromBeginning(playlistWithSongs.songs.map(SongWithInfo::asMediaItem))
|
||||
}
|
||||
binder?.stopRadio()
|
||||
binder?.player?.forcePlayFromBeginning(playlistWithSongs.songs.map(SongWithInfo::asMediaItem))
|
||||
}
|
||||
.shadow(elevation = 2.dp, shape = CircleShape)
|
||||
.background(
|
||||
@@ -280,10 +270,8 @@ fun LocalPlaylistScreen(
|
||||
song = song,
|
||||
thumbnailSize = thumbnailSize,
|
||||
onClick = {
|
||||
player?.mediaController?.let {
|
||||
it.sendCustomCommand(StopRadioCommand, Bundle.EMPTY)
|
||||
it.forcePlayAtIndex(playlistWithSongs.songs.map(SongWithInfo::asMediaItem), index)
|
||||
}
|
||||
binder?.stopRadio()
|
||||
binder?.player?.forcePlayAtIndex(playlistWithSongs.songs.map(SongWithInfo::asMediaItem), index)
|
||||
},
|
||||
menuContent = {
|
||||
InPlaylistMediaItemMenu(
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package it.vfsfitvnm.vimusic.ui.screens
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import androidx.compose.animation.ExperimentalAnimationApi
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.background
|
||||
@@ -25,17 +24,16 @@ import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.media3.common.Player
|
||||
import coil.compose.AsyncImage
|
||||
import com.valentinilk.shimmer.shimmer
|
||||
import it.vfsfitvnm.route.RouteHandler
|
||||
import it.vfsfitvnm.vimusic.Database
|
||||
import it.vfsfitvnm.vimusic.LocalPlayerServiceBinder
|
||||
import it.vfsfitvnm.vimusic.R
|
||||
import it.vfsfitvnm.vimusic.enums.ThumbnailRoundness
|
||||
import it.vfsfitvnm.vimusic.internal
|
||||
import it.vfsfitvnm.vimusic.models.Playlist
|
||||
import it.vfsfitvnm.vimusic.models.SongInPlaylist
|
||||
import it.vfsfitvnm.vimusic.services.StopRadioCommand
|
||||
import it.vfsfitvnm.vimusic.ui.components.LocalMenuState
|
||||
import it.vfsfitvnm.vimusic.ui.components.OutcomeItem
|
||||
import it.vfsfitvnm.vimusic.ui.components.TopAppBar
|
||||
@@ -87,7 +85,8 @@ fun PlaylistOrAlbumScreen(
|
||||
host {
|
||||
val context = LocalContext.current
|
||||
val density = LocalDensity.current
|
||||
val player = LocalYoutubePlayer.current
|
||||
val binder = LocalPlayerServiceBinder.current
|
||||
|
||||
val colorPalette = LocalColorPalette.current
|
||||
val typography = LocalTypography.current
|
||||
val menuState = LocalMenuState.current
|
||||
@@ -142,7 +141,6 @@ fun PlaylistOrAlbumScreen(
|
||||
MenuEntry(
|
||||
icon = R.drawable.time,
|
||||
text = "Enqueue",
|
||||
enabled = player?.playbackState == Player.STATE_READY,
|
||||
onClick = {
|
||||
menuState.hide()
|
||||
playlistOrAlbum.valueOrNull?.let { album ->
|
||||
@@ -151,7 +149,7 @@ fun PlaylistOrAlbumScreen(
|
||||
song.toMediaItem(browseId, album)
|
||||
}
|
||||
?.let { mediaItems ->
|
||||
player?.mediaController?.enqueue(
|
||||
binder?.player?.enqueue(
|
||||
mediaItems
|
||||
)
|
||||
}
|
||||
@@ -282,16 +280,14 @@ fun PlaylistOrAlbumScreen(
|
||||
colorFilter = ColorFilter.tint(colorPalette.text),
|
||||
modifier = Modifier
|
||||
.clickable {
|
||||
player?.mediaController?.let {
|
||||
it.sendCustomCommand(StopRadioCommand, Bundle.EMPTY)
|
||||
playlistOrAlbum.items
|
||||
?.shuffled()
|
||||
?.mapNotNull { song ->
|
||||
song.toMediaItem(browseId, playlistOrAlbum)
|
||||
}?.let { mediaItems ->
|
||||
it.forcePlayFromBeginning(mediaItems)
|
||||
}
|
||||
}
|
||||
binder?.stopRadio()
|
||||
playlistOrAlbum.items
|
||||
?.shuffled()
|
||||
?.mapNotNull { song ->
|
||||
song.toMediaItem(browseId, playlistOrAlbum)
|
||||
}?.let { mediaItems ->
|
||||
binder?.player?.forcePlayFromBeginning(mediaItems)
|
||||
}
|
||||
}
|
||||
.shadow(elevation = 2.dp, shape = CircleShape)
|
||||
.background(
|
||||
@@ -308,13 +304,11 @@ fun PlaylistOrAlbumScreen(
|
||||
colorFilter = ColorFilter.tint(colorPalette.text),
|
||||
modifier = Modifier
|
||||
.clickable {
|
||||
player?.mediaController?.let {
|
||||
it.sendCustomCommand(StopRadioCommand, Bundle.EMPTY)
|
||||
playlistOrAlbum.items?.mapNotNull { song ->
|
||||
song.toMediaItem(browseId, playlistOrAlbum)
|
||||
}?.let { mediaItems ->
|
||||
it.forcePlayFromBeginning(mediaItems)
|
||||
}
|
||||
binder?.stopRadio()
|
||||
playlistOrAlbum.items?.mapNotNull { song ->
|
||||
song.toMediaItem(browseId, playlistOrAlbum)
|
||||
}?.let { mediaItems ->
|
||||
binder?.player?.forcePlayFromBeginning(mediaItems)
|
||||
}
|
||||
}
|
||||
.shadow(elevation = 2.dp, shape = CircleShape)
|
||||
@@ -340,13 +334,11 @@ fun PlaylistOrAlbumScreen(
|
||||
authors = (song.authors ?: playlistOrAlbum.valueOrNull?.authors)?.joinToString("") { it.name },
|
||||
durationText = song.durationText,
|
||||
onClick = {
|
||||
player?.mediaController?.let {
|
||||
it.sendCustomCommand(StopRadioCommand, Bundle.EMPTY)
|
||||
playlistOrAlbum.valueOrNull?.items?.mapNotNull { song ->
|
||||
song.toMediaItem(browseId, playlistOrAlbum.valueOrNull!!)
|
||||
}?.let { mediaItems ->
|
||||
it.forcePlayAtIndex(mediaItems, index)
|
||||
}
|
||||
binder?.stopRadio()
|
||||
playlistOrAlbum.valueOrNull?.items?.mapNotNull { song ->
|
||||
song.toMediaItem(browseId, playlistOrAlbum.valueOrNull!!)
|
||||
}?.let { mediaItems ->
|
||||
binder?.player?.forcePlayAtIndex(mediaItems, index)
|
||||
}
|
||||
},
|
||||
startContent = {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package it.vfsfitvnm.vimusic.ui.screens
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.compose.animation.ExperimentalAnimationApi
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.background
|
||||
@@ -26,16 +25,15 @@ import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.core.os.bundleOf
|
||||
import coil.compose.AsyncImage
|
||||
import com.valentinilk.shimmer.Shimmer
|
||||
import com.valentinilk.shimmer.ShimmerBounds
|
||||
import com.valentinilk.shimmer.rememberShimmer
|
||||
import com.valentinilk.shimmer.shimmer
|
||||
import it.vfsfitvnm.route.RouteHandler
|
||||
import it.vfsfitvnm.vimusic.LocalPlayerServiceBinder
|
||||
import it.vfsfitvnm.vimusic.R
|
||||
import it.vfsfitvnm.vimusic.enums.ThumbnailRoundness
|
||||
import it.vfsfitvnm.vimusic.services.StartRadioCommand
|
||||
import it.vfsfitvnm.vimusic.ui.components.*
|
||||
import it.vfsfitvnm.vimusic.ui.components.themed.NonQueuedMediaItemMenu
|
||||
import it.vfsfitvnm.vimusic.ui.components.themed.TextPlaceholder
|
||||
@@ -45,7 +43,6 @@ import it.vfsfitvnm.vimusic.ui.views.SongItem
|
||||
import it.vfsfitvnm.vimusic.utils.*
|
||||
import it.vfsfitvnm.youtubemusic.Outcome
|
||||
import it.vfsfitvnm.youtubemusic.YouTube
|
||||
import it.vfsfitvnm.youtubemusic.models.NavigationEndpoint
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
@@ -60,7 +57,7 @@ fun SearchResultScreen(
|
||||
val colorPalette = LocalColorPalette.current
|
||||
val typography = LocalTypography.current
|
||||
val preferences = LocalPreferences.current
|
||||
val player = LocalYoutubePlayer.current
|
||||
val binder = LocalPlayerServiceBinder.current
|
||||
|
||||
val lazyListState = rememberLazyListState()
|
||||
|
||||
@@ -218,13 +215,13 @@ fun SearchResultScreen(
|
||||
is YouTube.Item.Album -> playlistOrAlbumRoute(item.info.endpoint!!.browseId)
|
||||
is YouTube.Item.Artist -> artistRoute(item.info.endpoint!!.browseId)
|
||||
is YouTube.Item.Playlist -> playlistOrAlbumRoute(item.info.endpoint!!.browseId)
|
||||
is YouTube.Item.Song -> player?.mediaController?.let {
|
||||
it.forcePlay(item.asMediaItem)
|
||||
it.sendCustomCommand(StartRadioCommand, item.info.endpoint.asBundle)
|
||||
is YouTube.Item.Song -> {
|
||||
binder?.player?.forcePlay(item.asMediaItem)
|
||||
binder?.startRadio(item.info.endpoint)
|
||||
}
|
||||
is YouTube.Item.Video -> player?.mediaController?.let {
|
||||
it.forcePlay(item.asMediaItem)
|
||||
it.sendCustomCommand(StartRadioCommand, item.info.endpoint.asBundle)
|
||||
is YouTube.Item.Video -> {
|
||||
binder?.player?.forcePlay(item.asMediaItem)
|
||||
binder?.startRadio(item.info.endpoint)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -573,13 +570,3 @@ fun SmallArtistItem(
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
val NavigationEndpoint.Endpoint.Watch?.asBundle: Bundle
|
||||
get() = this?.let {
|
||||
bundleOf(
|
||||
"videoId" to videoId,
|
||||
"playlistId" to playlistId,
|
||||
"playlistSetVideoId" to playlistSetVideoId,
|
||||
"params" to params,
|
||||
)
|
||||
} ?: Bundle.EMPTY
|
||||
@@ -1,6 +1,5 @@
|
||||
package it.vfsfitvnm.vimusic.ui.screens.settings
|
||||
|
||||
import android.os.Bundle
|
||||
import android.text.format.Formatter
|
||||
import androidx.compose.animation.ExperimentalAnimationApi
|
||||
import androidx.compose.foundation.*
|
||||
@@ -16,19 +15,17 @@ import androidx.compose.ui.unit.dp
|
||||
import coil.Coil
|
||||
import coil.annotation.ExperimentalCoilApi
|
||||
import it.vfsfitvnm.route.RouteHandler
|
||||
import it.vfsfitvnm.vimusic.LocalPlayerServiceBinder
|
||||
import it.vfsfitvnm.vimusic.R
|
||||
import it.vfsfitvnm.vimusic.services.GetCacheSizeCommand
|
||||
import it.vfsfitvnm.vimusic.ui.components.SeekBar
|
||||
import it.vfsfitvnm.vimusic.ui.components.TopAppBar
|
||||
import it.vfsfitvnm.vimusic.ui.screens.*
|
||||
import it.vfsfitvnm.vimusic.ui.styling.LocalColorPalette
|
||||
import it.vfsfitvnm.vimusic.ui.styling.LocalTypography
|
||||
import it.vfsfitvnm.vimusic.utils.LocalPreferences
|
||||
import it.vfsfitvnm.vimusic.utils.LocalYoutubePlayer
|
||||
import it.vfsfitvnm.vimusic.utils.secondary
|
||||
import it.vfsfitvnm.vimusic.utils.semiBold
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.guava.await
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
@OptIn(ExperimentalCoilApi::class)
|
||||
@@ -58,9 +55,7 @@ fun OtherSettingsScreen() {
|
||||
val colorPalette = LocalColorPalette.current
|
||||
val typography = LocalTypography.current
|
||||
val preferences = LocalPreferences.current
|
||||
val mediaController = LocalYoutubePlayer.current?.mediaController
|
||||
|
||||
val coilDiskCache = Coil.imageLoader(context).diskCache
|
||||
val binder = LocalPlayerServiceBinder.current
|
||||
|
||||
val coroutineScope = rememberCoroutineScope()
|
||||
|
||||
@@ -97,7 +92,7 @@ fun OtherSettingsScreen() {
|
||||
)
|
||||
}
|
||||
|
||||
coilDiskCache?.let { diskCache ->
|
||||
Coil.imageLoader(context).diskCache?.let { diskCache ->
|
||||
var diskCacheSize by remember(diskCache) {
|
||||
mutableStateOf(diskCache.size)
|
||||
}
|
||||
@@ -168,9 +163,11 @@ fun OtherSettingsScreen() {
|
||||
)
|
||||
}
|
||||
|
||||
mediaController?.let { mediaController ->
|
||||
val diskCacheSize by produceState(initialValue = 0L) {
|
||||
value = mediaController.sendCustomCommand(GetCacheSizeCommand, Bundle.EMPTY).await().extras.getLong("cacheSize")
|
||||
binder?.cache?.let { cache ->
|
||||
val diskCacheSize by remember {
|
||||
derivedStateOf {
|
||||
cache.cacheSpace
|
||||
}
|
||||
}
|
||||
|
||||
var scrubbingDiskCacheMaxSize by remember {
|
||||
|
||||
@@ -2,7 +2,6 @@ package it.vfsfitvnm.vimusic.ui.screens.settings
|
||||
|
||||
import android.content.Intent
|
||||
import android.media.audiofx.AudioEffect
|
||||
import android.os.Bundle
|
||||
import android.text.format.DateUtils
|
||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
@@ -18,12 +17,9 @@ import androidx.compose.ui.graphics.ColorFilter
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.media3.common.C
|
||||
import androidx.media3.session.SessionResult
|
||||
import it.vfsfitvnm.route.RouteHandler
|
||||
import it.vfsfitvnm.vimusic.LocalPlayerServiceBinder
|
||||
import it.vfsfitvnm.vimusic.R
|
||||
import it.vfsfitvnm.vimusic.services.*
|
||||
import it.vfsfitvnm.vimusic.ui.components.ChunkyButton
|
||||
import it.vfsfitvnm.vimusic.ui.components.Pager
|
||||
import it.vfsfitvnm.vimusic.ui.components.TopAppBar
|
||||
@@ -32,10 +28,10 @@ import it.vfsfitvnm.vimusic.ui.components.themed.DefaultDialog
|
||||
import it.vfsfitvnm.vimusic.ui.screens.*
|
||||
import it.vfsfitvnm.vimusic.ui.styling.LocalColorPalette
|
||||
import it.vfsfitvnm.vimusic.ui.styling.LocalTypography
|
||||
import it.vfsfitvnm.vimusic.utils.*
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.guava.await
|
||||
import kotlinx.coroutines.isActive
|
||||
import it.vfsfitvnm.vimusic.utils.LocalPreferences
|
||||
import it.vfsfitvnm.vimusic.utils.color
|
||||
import it.vfsfitvnm.vimusic.utils.semiBold
|
||||
import kotlinx.coroutines.flow.flowOf
|
||||
|
||||
|
||||
@ExperimentalAnimationApi
|
||||
@@ -64,39 +60,23 @@ fun PlayerSettingsScreen() {
|
||||
val colorPalette = LocalColorPalette.current
|
||||
val typography = LocalTypography.current
|
||||
val preferences = LocalPreferences.current
|
||||
val mediaController = LocalYoutubePlayer.current?.mediaController
|
||||
val binder = LocalPlayerServiceBinder.current
|
||||
|
||||
val activityResultLauncher =
|
||||
rememberLauncherForActivityResult(ActivityResultContracts.StartActivityForResult()) {
|
||||
}
|
||||
|
||||
val audioSessionId by produceState(initialValue = C.AUDIO_SESSION_ID_UNSET, mediaController) {
|
||||
val audioSessionId = remember(binder) {
|
||||
val hasEqualizer = context.packageManager.resolveActivity(
|
||||
Intent(AudioEffect.ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL),
|
||||
0
|
||||
) != null
|
||||
|
||||
if (hasEqualizer) {
|
||||
value =
|
||||
mediaController?.sendCustomCommand(GetAudioSessionIdCommand, Bundle.EMPTY)
|
||||
?.await()?.extras?.getInt("audioSessionId", C.AUDIO_SESSION_ID_UNSET)
|
||||
?: C.AUDIO_SESSION_ID_UNSET
|
||||
}
|
||||
if (hasEqualizer) binder?.player?.audioSessionId else null
|
||||
}
|
||||
|
||||
var sleepTimerMillisLeft by remember {
|
||||
mutableStateOf<Long?>(null)
|
||||
}
|
||||
|
||||
LaunchedEffect(mediaController) {
|
||||
while (isActive) {
|
||||
sleepTimerMillisLeft =
|
||||
mediaController?.syncCommand(GetSleepTimerMillisLeftCommand)
|
||||
?.takeIf { it.resultCode == SessionResult.RESULT_SUCCESS }
|
||||
?.extras?.getLong("millisLeft")
|
||||
delay(1000)
|
||||
}
|
||||
}
|
||||
val sleepTimerMillisLeft by (binder?.sleepTimerMillisLeft
|
||||
?: flowOf(null)).collectAsState(initial = null)
|
||||
|
||||
var isShowingSleepTimerDialog by remember {
|
||||
mutableStateOf(false)
|
||||
@@ -112,8 +92,7 @@ fun PlayerSettingsScreen() {
|
||||
isShowingSleepTimerDialog = false
|
||||
},
|
||||
onConfirm = {
|
||||
mediaController?.syncCommand(CancelSleepTimerCommand)
|
||||
sleepTimerMillisLeft = null
|
||||
binder?.cancelSleepTimer()
|
||||
}
|
||||
)
|
||||
} else {
|
||||
@@ -199,14 +178,7 @@ fun PlayerSettingsScreen() {
|
||||
shape = RoundedCornerShape(36.dp),
|
||||
isEnabled = hours > 0 || minutes > 0,
|
||||
onClick = {
|
||||
mediaController?.syncCommand(
|
||||
SetSleepTimerCommand,
|
||||
bundleOf("delayMillis" to (hours * 60 + minutes * 15) * 60 * 1000L)
|
||||
)
|
||||
sleepTimerMillisLeft =
|
||||
mediaController?.syncCommand(GetSleepTimerMillisLeftCommand)?.extras?.getLong(
|
||||
"millisLeft"
|
||||
)
|
||||
binder?.startSleepTimer((hours * 60 + minutes * 15) * 60 * 1000L)
|
||||
isShowingSleepTimerDialog = false
|
||||
}
|
||||
)
|
||||
@@ -253,10 +225,7 @@ fun PlayerSettingsScreen() {
|
||||
text = "Skip silent parts during playback",
|
||||
isChecked = preferences.skipSilence,
|
||||
onCheckedChange = {
|
||||
mediaController?.sendCustomCommand(
|
||||
SetSkipSilenceCommand,
|
||||
bundleOf("skipSilence" to it)
|
||||
)
|
||||
binder?.player?.skipSilenceEnabled = it
|
||||
preferences.skipSilence = it
|
||||
}
|
||||
)
|
||||
@@ -284,7 +253,7 @@ fun PlayerSettingsScreen() {
|
||||
}
|
||||
)
|
||||
},
|
||||
isEnabled = audioSessionId != C.AUDIO_SESSION_ID_UNSET && audioSessionId != AudioEffect.ERROR_BAD_VALUE
|
||||
isEnabled = audioSessionId != null
|
||||
)
|
||||
|
||||
SettingsEntry(
|
||||
|
||||
Reference in New Issue
Block a user