make it possible to switch to fullscreen
This commit is contained in:
parent
f4264c3892
commit
09815ccb12
|
@ -29,6 +29,9 @@ import androidx.compose.ui.platform.ComposeView
|
|||
import androidx.compose.ui.platform.ViewCompositionStrategy
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.view.WindowCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.core.view.WindowInsetsControllerCompat
|
||||
import androidx.core.view.updateLayoutParams
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.viewModels
|
||||
|
@ -50,10 +53,19 @@ class PlayerFragment() : Fragment() {
|
|||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
val window = activity?.window!!
|
||||
val insetsController = WindowCompat.getInsetsController(window, window.decorView)
|
||||
insetsController.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
|
||||
|
||||
val view = inflater.inflate(R.layout.player_framgent, container, false)
|
||||
val composeView = view.findViewById<ComposeView>(R.id.player_copose_view)
|
||||
val frameView = view.findViewById<FrameLayout>(R.id.frame_layout)
|
||||
|
||||
if (viewModel.uiState.value.fullscreen) {
|
||||
println("gurken fragment created for fullscreen")
|
||||
insetsController.hide(WindowInsetsCompat.Type.systemBars())
|
||||
}
|
||||
|
||||
viewModel.listener = object : VideoPlayerViewModel.Listener {
|
||||
override fun requestUpdateLayoutRatio(ratio: Float) {
|
||||
frameView.updateLayoutParams<ConstraintLayout.LayoutParams> {
|
||||
|
@ -62,10 +74,7 @@ class PlayerFragment() : Fragment() {
|
|||
}
|
||||
|
||||
override fun switchToFullscreen() {
|
||||
frameView.updateLayoutParams<ConstraintLayout.LayoutParams> {
|
||||
|
||||
println("gurken fullscreen")
|
||||
}
|
||||
println("gurken fullscreen")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
package net.newpipe.newplayer.ui
|
||||
|
||||
import android.content.pm.ActivityInfo
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
|
@ -121,6 +122,11 @@ fun VideoPlayerControllerUI(
|
|||
)
|
||||
}
|
||||
}
|
||||
if (isFullscreen) {
|
||||
BackHandler {
|
||||
switchToEmbeddedView()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
@ -350,7 +356,7 @@ private fun BottomUI(
|
|||
Text("00:06:45")
|
||||
Slider(value = 0.4F, onValueChange = {}, modifier = Modifier.weight(1F))
|
||||
Text("00:09:40")
|
||||
IconButton(onClick = if(isFullscreen) switchToEmbeddedView else switchToFullscreen) {
|
||||
IconButton(onClick = if (isFullscreen) switchToEmbeddedView else switchToFullscreen) {
|
||||
Icon(
|
||||
imageVector = if (isFullscreen) Icons.Filled.FullscreenExit
|
||||
else Icons.Filled.Fullscreen,
|
||||
|
|
|
@ -26,6 +26,7 @@ import android.content.ContextWrapper
|
|||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.DisposableEffect
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.core.view.WindowCompat
|
||||
|
||||
@Composable
|
||||
fun LockScreenOrientation(orientation: Int) {
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- NewPlayer
|
||||
|
||||
@author Christian Schabesberger
|
||||
|
||||
Copyright (C) NewPipe e.V. 2024 <code(at)newpipe-ev.de>
|
||||
|
||||
NewPlayer is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
NewPlayer is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with NewPlayer. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/frame_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.compose.ui.platform.ComposeView
|
||||
android:id="@+id/player_copose_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
Reference in New Issue