fix some more fullscreen shit

This commit is contained in:
Christian Schabesberger 2024-07-23 17:26:42 +02:00
parent b95db7cd07
commit b3b7bb18ea
4 changed files with 54 additions and 18 deletions

View File

@ -4,7 +4,7 @@
<selectionStates> <selectionStates>
<SelectionState runConfigName="TestApp"> <SelectionState runConfigName="TestApp">
<option name="selectionMode" value="DROPDOWN" /> <option name="selectionMode" value="DROPDOWN" />
<DropdownSelection timestamp="2024-07-23T14:30:02.857797708Z"> <DropdownSelection timestamp="2024-07-23T15:11:36.844182977Z">
<Target type="DEFAULT_BOOT"> <Target type="DEFAULT_BOOT">
<handle> <handle>
<DeviceId pluginId="PhysicalDevice" identifier="serial=981f7af2" /> <DeviceId pluginId="PhysicalDevice" identifier="serial=981f7af2" />

View File

@ -22,6 +22,7 @@ package net.newpipe.newplayer.testapp
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
import android.webkit.RenderProcessGoneDetail
import android.widget.Button import android.widget.Button
import androidx.activity.enableEdgeToEdge import androidx.activity.enableEdgeToEdge
import androidx.activity.viewModels import androidx.activity.viewModels
@ -54,13 +55,15 @@ class MainActivity : AppCompatActivity() {
val video_view = findViewById<VideoPlayerView>(R.id.new_player_video_view) val video_view = findViewById<VideoPlayerView>(R.id.new_player_video_view)
val start_stream_button = findViewById<Button>(R.id.start_stream_button) val start_stream_button = findViewById<Button>(R.id.start_stream_button)
val buttons_layout = findViewById<View>(R.id.buttons_layout) val buttons_layout = findViewById<View>(R.id.buttons_layout)
val embedded_player_layout = findViewById<View>(R.id.player_column)
val fullscreen_player = findViewById<VideoPlayerView>(R.id.fullscreen_player)
start_stream_button.setOnClickListener { start_stream_button.setOnClickListener {
newPlayer.playWhenReady = true newPlayer.playWhenReady = true
newPlayer.setStream(getString(R.string.ccc_chromebooks_video)) newPlayer.setStream(getString(R.string.ccc_6502_video))
} }
video_view.viewModel = videoPlayerViewModel
videoPlayerViewModel.newPlayer = newPlayer videoPlayerViewModel.newPlayer = newPlayer
videoPlayerViewModel.maxContentRatio = 4F/3F videoPlayerViewModel.maxContentRatio = 4F/3F
@ -72,25 +75,20 @@ class MainActivity : AppCompatActivity() {
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets -> val setupFullscreen = {
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
v.setPadding(
systemBars.left,
systemBars.top,
systemBars.right,
systemBars.bottom
)
insets
}
if (videoPlayerViewModel.uiState.value.fullscreen) {
//ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets -> //ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
// v.setPadding(0, 0, 0, 0) // v.setPadding(0, 0, 0, 0)
// insets // insets
//} //}
buttons_layout.visibility = View.GONE buttons_layout.visibility = View.GONE
embedded_player_layout.visibility = View.GONE
fullscreen_player.visibility = View.VISIBLE
fullscreen_player.viewModel = videoPlayerViewModel
//windowInsetsController.hide(WindowInsetsCompat.Type.systemBars()) //windowInsetsController.hide(WindowInsetsCompat.Type.systemBars())
} else { }
val setupEmbeddedView = {
buttons_layout.visibility = View.VISIBLE buttons_layout.visibility = View.VISIBLE
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets -> ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
@ -104,11 +102,28 @@ class MainActivity : AppCompatActivity() {
insets insets
} }
buttons_layout.visibility = View.VISIBLE
embedded_player_layout.visibility = View.VISIBLE
fullscreen_player.visibility = View.GONE
video_view.viewModel = videoPlayerViewModel
//windowInsetsController.show(WindowInsetsCompat.Type.systemBars()) //windowInsetsController.show(WindowInsetsCompat.Type.systemBars())
} }
if (videoPlayerViewModel.uiState.value.fullscreen) {
setupFullscreen()
} else {
setupEmbeddedView()
}
videoPlayerViewModel.callbackListener = object : VideoPlayerViewModel.Listener { videoPlayerViewModel.callbackListener = object : VideoPlayerViewModel.Listener {
override fun onFullscreenToggle(isFullscreen: Boolean) {} override fun onFullscreenToggle(isFullscreen: Boolean) {
if (isFullscreen)
setupFullscreen()
else
setupEmbeddedView()
}
override fun onUiVissibleToggle(isVissible: Boolean) { override fun onUiVissibleToggle(isVissible: Boolean) {
if (isVissible) { if (isVissible) {
@ -118,6 +133,5 @@ class MainActivity : AppCompatActivity() {
} }
} }
} }
} }
} }

View File

@ -27,6 +27,17 @@
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".MainActivity"> tools:context=".MainActivity">
<net.newpipe.newplayer.VideoPlayerView
android:id="@+id/fullscreen_player"
android:name="net.newpipe.newplayer.VideoPlayerFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minHeight="50dp"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout <LinearLayout
android:id="@+id/player_column" android:id="@+id/player_column"

View File

@ -26,6 +26,17 @@
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".MainActivity"> tools:context=".MainActivity">
<net.newpipe.newplayer.VideoPlayerView
android:id="@+id/fullscreen_player"
android:name="net.newpipe.newplayer.VideoPlayerFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minHeight="50dp"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<FrameLayout <FrameLayout
android:id="@+id/player_column" android:id="@+id/player_column"