Skip to content

Commit

Permalink
make aspect ratio of pip view update when the content aspect ratio ch…
Browse files Browse the repository at this point in the history
…anges
  • Loading branch information
theScrabi committed Nov 1, 2024
1 parent de393cf commit c5ae059
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import net.newpipe.newplayer.ui.selection_ui.ChapterSelectUI
import net.newpipe.newplayer.ui.videoplayer.pip.getPipParams
import net.newpipe.newplayer.ui.videoplayer.pip.supportsPip
import net.newpipe.newplayer.ui.common.getEmbeddedUiConfig
import net.newpipe.newplayer.uiModel.UIModeState

@OptIn(UnstableApi::class)
@Composable
Expand Down Expand Up @@ -93,6 +94,19 @@ internal fun VideoPlayerUi(viewModel: InternalNewPlayerViewModel, uiState: NewPl
}
}

// this is there to update the aspect ratio of the pip window the aspect ratio of the
// content changes.
LaunchedEffect(uiState.contentRatio) {
if (uiState.uiMode == UIModeState.PIP
&& Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
&& supportsPip(activity)
) {
val pipParams = getPipParams(uiState.contentRatio, videoViewBounds)
if(pipParams != null)
activity.setPictureInPictureParams(pipParams)
}
}

Surface(
modifier = Modifier
.then(
Expand Down Expand Up @@ -128,7 +142,7 @@ internal fun VideoPlayerUi(viewModel: InternalNewPlayerViewModel, uiState: NewPl

// Disable this animation as it induces ghost tabs
//AnimatedVisibility(visible = uiState.uiMode.isStreamSelect) {
if(uiState.uiMode.isStreamSelect) {
if (uiState.uiMode.isStreamSelect) {
Surface(
modifier = Modifier.fillMaxSize(),
color = STREAMSELECT_UI_BACKGROUND_COLOR
Expand All @@ -143,7 +157,7 @@ internal fun VideoPlayerUi(viewModel: InternalNewPlayerViewModel, uiState: NewPl

// Disable this animation as it induces ghost tabs
//AnimatedVisibility(visible = uiState.uiMode.isChapterSelect) {
if(uiState.uiMode.isChapterSelect) {
if (uiState.uiMode.isChapterSelect) {
Surface(
modifier = Modifier.fillMaxSize(),
color = STREAMSELECT_UI_BACKGROUND_COLOR
Expand Down

0 comments on commit c5ae059

Please sign in to comment.