-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: scale video in Surface with controls, improve focus handling, a…
…dd fullscreen handling
- Loading branch information
1 parent
89e9090
commit b540abd
Showing
7 changed files
with
149 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 25 additions & 7 deletions
32
src/main/kotlin/dev/silenium/multimedia/compose/player/VideoSurfaceWithControls.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,40 @@ | ||
package dev.silenium.multimedia.compose.player | ||
|
||
import androidx.compose.foundation.layout.BoxWithConstraints | ||
import androidx.compose.foundation.layout.requiredSizeIn | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import dev.silenium.multimedia.core.annotation.InternalMultimediaApi | ||
|
||
@OptIn(InternalMultimediaApi::class) | ||
@Composable | ||
fun VideoSurfaceWithControls( | ||
player: VideoPlayer, | ||
modifier: Modifier = Modifier, | ||
showStats: Boolean = false, | ||
onInitialized: () -> Unit = {}, | ||
) { | ||
BoxWithConstraints(modifier = modifier) { | ||
VideoSurface( | ||
player, showStats, | ||
onInitialized = onInitialized, | ||
modifier = Modifier.matchParentSize(), | ||
) | ||
VideoSurfaceControls(player, Modifier.matchParentSize()) | ||
BoxWithConstraints(modifier) { | ||
BoxWithConstraints( | ||
modifier = Modifier.requiredSizeIn( | ||
this@BoxWithConstraints.minWidth, | ||
this@BoxWithConstraints.minHeight, | ||
this@BoxWithConstraints.maxWidth, | ||
this@BoxWithConstraints.maxHeight, | ||
) | ||
) { | ||
VideoSurface( | ||
player, showStats, | ||
onInitialized = onInitialized, | ||
modifier = Modifier.align(Alignment.Center).requiredSizeIn( | ||
minWidth = minWidth, | ||
minHeight = minHeight, | ||
maxWidth = maxWidth, | ||
maxHeight = maxHeight, | ||
), | ||
) | ||
VideoSurfaceControls(player, Modifier.matchParentSize()) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/main/kotlin/dev/silenium/multimedia/compose/util/FullscreenProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package dev.silenium.multimedia.compose.util | ||
|
||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.setValue | ||
import androidx.compose.runtime.staticCompositionLocalOf | ||
import androidx.compose.ui.window.WindowPlacement | ||
import androidx.compose.ui.window.WindowState | ||
|
||
class FullscreenProvider { | ||
var isFullscreen by mutableStateOf(false) | ||
private set | ||
val windowState = WindowState() | ||
|
||
@Synchronized | ||
fun toggleFullscreen() { | ||
isFullscreen = !isFullscreen | ||
windowState.placement = if (isFullscreen) WindowPlacement.Fullscreen else WindowPlacement.Floating | ||
} | ||
} | ||
|
||
val LocalFullscreenProvider = staticCompositionLocalOf { FullscreenProvider() } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters