diff --git a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/details/components/TrailerPlayerPopup.kt b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/details/components/TrailerPlayerPopup.kt index c12ead6b..09976eba 100644 --- a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/details/components/TrailerPlayerPopup.kt +++ b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/details/components/TrailerPlayerPopup.kt @@ -6,6 +6,7 @@ import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.aspectRatio +import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.shape.RoundedCornerShape @@ -173,7 +174,7 @@ fun TrailerPlayerPopup( sourceUrl = playbackSource.videoUrl, sourceAudioUrl = playbackSource.audioUrl, useYoutubeChunkedPlayback = true, - modifier = Modifier.fillMaxWidth(), + modifier = Modifier.fillMaxSize(), playWhenReady = true, resizeMode = PlayerResizeMode.Fit, useNativeController = true, diff --git a/composeApp/src/iosMain/kotlin/com/nuvio/app/features/player/PlayerEngine.ios.kt b/composeApp/src/iosMain/kotlin/com/nuvio/app/features/player/PlayerEngine.ios.kt index c122cacc..261e73ac 100644 --- a/composeApp/src/iosMain/kotlin/com/nuvio/app/features/player/PlayerEngine.ios.kt +++ b/composeApp/src/iosMain/kotlin/com/nuvio/app/features/player/PlayerEngine.ios.kt @@ -4,9 +4,21 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.setValue import androidx.compose.runtime.remember import androidx.compose.runtime.rememberUpdatedState +import androidx.compose.foundation.background +import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.size +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.rounded.PlayArrow +import androidx.compose.material3.Icon +import androidx.compose.ui.Alignment import androidx.compose.ui.graphics.Color +import androidx.compose.ui.unit.dp import androidx.compose.ui.Modifier import androidx.compose.ui.interop.UIKitViewController import androidx.lifecycle.compose.collectAsStateWithLifecycle @@ -88,6 +100,23 @@ actual fun PlatformPlayerSurface( bridge.setPlaybackSpeed(speed) } + override fun currentPlayerVolume(): PlayerAudioLevel { + val current = bridge.getVolume().coerceIn(0f, 2f) + return PlayerAudioLevel( + fraction = current, + isMuted = current <= 0.001f, + ) + } + + override fun setPlayerVolume(level: Float): PlayerAudioLevel { + val target = level.coerceIn(0f, 2f) + bridge.setVolume(target) + return PlayerAudioLevel( + fraction = target, + isMuted = target <= 0.001f, + ) + } + override fun setMuted(muted: Boolean) { bridge.setMuted(muted) } @@ -302,11 +331,42 @@ actual fun PlatformPlayerSurface( } // Render the player view - UIKitViewController( - factory = { bridge.createPlayerViewController() }, - modifier = modifier, - interactive = false, - ) + Box(modifier = modifier) { + UIKitViewController( + factory = { bridge.createPlayerViewController() }, + modifier = Modifier.fillMaxSize(), + interactive = false, + ) + + if (useNativeController) { + var isPlayingLocal by remember { mutableStateOf(playWhenReady) } + + Box( + modifier = Modifier + .fillMaxSize() + .background(if (!isPlayingLocal) Color.Black.copy(alpha = 0.4f) else Color.Transparent) + .clickable { + if (isPlayingLocal) { + bridge.pause() + isPlayingLocal = false + } else { + bridge.play() + isPlayingLocal = true + } + }, + contentAlignment = Alignment.Center + ) { + if (!isPlayingLocal) { + Icon( + imageVector = Icons.Rounded.PlayArrow, + contentDescription = "Play", + tint = Color.White, + modifier = Modifier.size(64.dp) + ) + } + } + } + } } private fun NuvioPlayerBridge.applyIosVideoOutputSettings(settings: PlayerSettingsUiState) {