make embedded audio player fit in its place
This commit is contained in:
parent
40b0ee5c6f
commit
f544d8bc76
|
@ -70,7 +70,7 @@ fun AudioPlayerEmbeddedUI(viewModel: NewPlayerViewModel, uiState: NewPlayerUISta
|
||||||
else
|
else
|
||||||
EmbeddedUiConfig.DUMMY
|
EmbeddedUiConfig.DUMMY
|
||||||
|
|
||||||
Box(modifier = Modifier.fillMaxSize()) {
|
Box(modifier = Modifier.wrapContentSize()) {
|
||||||
Thumbnail(
|
Thumbnail(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
thumbnail = uiState.currentlyPlaying?.mediaMetadata?.artworkUri,
|
thumbnail = uiState.currentlyPlaying?.mediaMetadata?.artworkUri,
|
||||||
|
@ -139,12 +139,19 @@ fun AudioPlayerEmbeddedUI(viewModel: NewPlayerViewModel, uiState: NewPlayerUISta
|
||||||
.align(Alignment.BottomStart)
|
.align(Alignment.BottomStart)
|
||||||
.fillMaxWidth(),
|
.fillMaxWidth(),
|
||||||
progress = {
|
progress = {
|
||||||
uiState.playbackPositionInMs.toFloat() / uiState.durationInMs.toFloat()
|
val duration = if (uiState.durationInMs == 0L) {
|
||||||
|
0.000000001f
|
||||||
|
} else {
|
||||||
|
uiState.durationInMs.toFloat()
|
||||||
|
}
|
||||||
|
|
||||||
|
(uiState.playbackPositionInMs.toFloat() / duration)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
Surface(modifier = Modifier
|
Surface(
|
||||||
.fillMaxSize()
|
modifier = Modifier
|
||||||
|
.matchParentSize()
|
||||||
.clickable {
|
.clickable {
|
||||||
viewModel.changeUiMode(
|
viewModel.changeUiMode(
|
||||||
UIModeState.FULLSCREEN_AUDIO,
|
UIModeState.FULLSCREEN_AUDIO,
|
||||||
|
@ -158,7 +165,7 @@ fun AudioPlayerEmbeddedUI(viewModel: NewPlayerViewModel, uiState: NewPlayerUISta
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(UnstableApi::class)
|
@OptIn(UnstableApi::class)
|
||||||
@Preview(device = "spec:width=1080px,height=600px,dpi=440,orientation=landscape")
|
@Preview(device = "spec:width=1080px,height=1080px,dpi=440,orientation=landscape")
|
||||||
@Composable
|
@Composable
|
||||||
fun AuidioPlayerEmbeddedPreview() {
|
fun AuidioPlayerEmbeddedPreview() {
|
||||||
VideoPlayerTheme {
|
VideoPlayerTheme {
|
||||||
|
|
|
@ -38,6 +38,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.width
|
import androidx.compose.foundation.layout.width
|
||||||
import androidx.compose.foundation.layout.windowInsetsPadding
|
import androidx.compose.foundation.layout.windowInsetsPadding
|
||||||
|
import androidx.compose.foundation.layout.wrapContentSize
|
||||||
import androidx.compose.material3.ButtonDefaults
|
import androidx.compose.material3.ButtonDefaults
|
||||||
import androidx.compose.material3.Card
|
import androidx.compose.material3.Card
|
||||||
import androidx.compose.material3.CardDefaults
|
import androidx.compose.material3.CardDefaults
|
||||||
|
@ -88,7 +89,7 @@ fun AudioPlayerUI(viewModel: NewPlayerViewModel, uiState: NewPlayerUIState, isLa
|
||||||
|
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxSize()
|
.wrapContentSize()
|
||||||
.background(color = MaterialTheme.colorScheme.background)
|
.background(color = MaterialTheme.colorScheme.background)
|
||||||
) {
|
) {
|
||||||
AnimatedVisibility(
|
AnimatedVisibility(
|
||||||
|
@ -364,3 +365,16 @@ fun AudioPlayerUILandscapePreview() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(UnstableApi::class)
|
||||||
|
@Preview(device = "spec:parent=pixel_6,orientation=portrait", showSystemUi = true)
|
||||||
|
@Composable
|
||||||
|
fun AudioPlayerUIEmbeddedPreview() {
|
||||||
|
VideoPlayerTheme {
|
||||||
|
AudioPlayerUI(
|
||||||
|
viewModel = NewPlayerViewModelDummy(),
|
||||||
|
uiState = NewPlayerUIState.DUMMY.copy(uiMode = UIModeState.EMBEDDED_AUDIO),
|
||||||
|
isLandScape = false
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
|
@ -110,7 +110,7 @@ fun AudioPlayerUIColorPreview() {
|
||||||
AudioPlayerUI(
|
AudioPlayerUI(
|
||||||
viewModel = NewPlayerViewModelDummy(),
|
viewModel = NewPlayerViewModelDummy(),
|
||||||
uiState = NewPlayerUIState.DUMMY.copy(
|
uiState = NewPlayerUIState.DUMMY.copy(
|
||||||
uiMode = UIModeState.EMBEDDED_VIDEO_CONTROLLER_UI,
|
uiMode = UIModeState.FULLSCREEN_AUDIO,
|
||||||
playing = true,
|
playing = true,
|
||||||
seekerPosition = 0.3f,
|
seekerPosition = 0.3f,
|
||||||
isLoading = false,
|
isLoading = false,
|
||||||
|
|
Loading…
Reference in New Issue