mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-07-29 23:59:32 +00:00
Merge pull request #1278 from luqmanfadlli/fix-ios-popup-trailer
fix(trailer): resolve iOS popup dimensions and polyfill native playback controls
This commit is contained in:
commit
2b885d7001
2 changed files with 67 additions and 6 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue