Only adds a border to video controls when in full screen
This commit is contained in:
@@ -43,10 +43,12 @@ import androidx.compose.ui.graphics.Color
|
|||||||
import androidx.compose.ui.layout.LayoutCoordinates
|
import androidx.compose.ui.layout.LayoutCoordinates
|
||||||
import androidx.compose.ui.layout.boundsInWindow
|
import androidx.compose.ui.layout.boundsInWindow
|
||||||
import androidx.compose.ui.layout.onGloballyPositioned
|
import androidx.compose.ui.layout.onGloballyPositioned
|
||||||
|
import androidx.compose.ui.layout.onSizeChanged
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.platform.LocalLifecycleOwner
|
import androidx.compose.ui.platform.LocalLifecycleOwner
|
||||||
import androidx.compose.ui.platform.LocalView
|
import androidx.compose.ui.platform.LocalView
|
||||||
import androidx.compose.ui.unit.Dp
|
import androidx.compose.ui.unit.Dp
|
||||||
|
import androidx.compose.ui.unit.IntSize
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.isFinite
|
import androidx.compose.ui.unit.isFinite
|
||||||
import androidx.compose.ui.unit.isSpecified
|
import androidx.compose.ui.unit.isSpecified
|
||||||
@@ -534,7 +536,25 @@ private fun RenderVideoPlayer(
|
|||||||
mutableStateOf(false)
|
mutableStateOf(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
BoxWithConstraints() {
|
val parentVideoPlaybackSize = remember {
|
||||||
|
mutableStateOf<IntSize>(IntSize.Zero)
|
||||||
|
}
|
||||||
|
|
||||||
|
val videoPlaybackSize = remember {
|
||||||
|
mutableStateOf<IntSize>(IntSize.Zero)
|
||||||
|
}
|
||||||
|
|
||||||
|
BoxWithConstraints(
|
||||||
|
contentAlignment = Alignment.Center,
|
||||||
|
modifier = Modifier.fillMaxSize().onSizeChanged {
|
||||||
|
parentVideoPlaybackSize.value = it
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
BoxWithConstraints(
|
||||||
|
modifier = Modifier.onSizeChanged {
|
||||||
|
videoPlaybackSize.value = it
|
||||||
|
}
|
||||||
|
) {
|
||||||
val borders = MaterialTheme.colorScheme.imageModifier
|
val borders = MaterialTheme.colorScheme.imageModifier
|
||||||
|
|
||||||
val myModifier = remember {
|
val myModifier = remember {
|
||||||
@@ -594,16 +614,22 @@ private fun RenderVideoPlayer(
|
|||||||
controller.volume < 0.001
|
controller.volume < 0.001
|
||||||
}
|
}
|
||||||
|
|
||||||
MuteButton(
|
val spaceModifier =
|
||||||
controllerVisible,
|
if (topPaddingForControllers.isSpecified && videoPlaybackSize.value.height > 0) {
|
||||||
startingMuteState,
|
val space = (abs(parentVideoPlaybackSize.value.height - videoPlaybackSize.value.height) / 2).dp
|
||||||
remember {
|
if (space > topPaddingForControllers) {
|
||||||
if (topPaddingForControllers.isSpecified) {
|
Modifier
|
||||||
Modifier.padding(top = topPaddingForControllers)
|
} else {
|
||||||
|
Modifier.padding(top = topPaddingForControllers - space)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Modifier
|
Modifier
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
MuteButton(
|
||||||
|
controllerVisible,
|
||||||
|
startingMuteState,
|
||||||
|
spaceModifier
|
||||||
) { mute: Boolean ->
|
) { mute: Boolean ->
|
||||||
// makes the new setting the default for new creations.
|
// makes the new setting the default for new creations.
|
||||||
DefaultMutedSetting.value = mute
|
DefaultMutedSetting.value = mute
|
||||||
@@ -621,13 +647,7 @@ private fun RenderVideoPlayer(
|
|||||||
KeepPlayingButton(
|
KeepPlayingButton(
|
||||||
keepPlaying,
|
keepPlaying,
|
||||||
controllerVisible,
|
controllerVisible,
|
||||||
remember {
|
spaceModifier.align(Alignment.TopEnd)
|
||||||
if (topPaddingForControllers.isSpecified) {
|
|
||||||
Modifier.align(Alignment.TopEnd).padding(top = topPaddingForControllers)
|
|
||||||
} else {
|
|
||||||
Modifier.align(Alignment.TopEnd)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
) { newKeepPlaying: Boolean ->
|
) { newKeepPlaying: Boolean ->
|
||||||
// If something else is playing and the user marks this video to keep playing, stops the other one.
|
// If something else is playing and the user marks this video to keep playing, stops the other one.
|
||||||
if (newKeepPlaying) {
|
if (newKeepPlaying) {
|
||||||
@@ -646,6 +666,7 @@ private fun RenderVideoPlayer(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun pollCurrentDuration(controller: MediaController) = flow {
|
private fun pollCurrentDuration(controller: MediaController) = flow {
|
||||||
while (controller.currentPosition <= controller.duration) {
|
while (controller.currentPosition <= controller.duration) {
|
||||||
|
|||||||
Reference in New Issue
Block a user