make modechange buttons of testapp work
This commit is contained in:
parent
39af73946c
commit
40b0ee5c6f
|
@ -26,6 +26,7 @@ import androidx.activity.enableEdgeToEdge
|
||||||
import androidx.activity.viewModels
|
import androidx.activity.viewModels
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
|
import kotlinx.coroutines.flow.update
|
||||||
import net.newpipe.newplayer.ActivityBrainSlug
|
import net.newpipe.newplayer.ActivityBrainSlug
|
||||||
import net.newpipe.newplayer.NewPlayer
|
import net.newpipe.newplayer.NewPlayer
|
||||||
import net.newpipe.newplayer.PlayMode
|
import net.newpipe.newplayer.PlayMode
|
||||||
|
@ -53,42 +54,54 @@ class MainActivity : AppCompatActivity() {
|
||||||
binding = ActivityMainBinding.inflate(layoutInflater)
|
binding = ActivityMainBinding.inflate(layoutInflater)
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
|
|
||||||
binding.start6502StreamButton.setOnClickListener {
|
binding.buttons.start6502StreamButton.setOnClickListener {
|
||||||
newPlayer.playWhenReady = true
|
newPlayer.playWhenReady = true
|
||||||
newPlayer.playStream("6502", PlayMode.EMBEDDED_VIDEO)
|
newPlayer.playStream("6502", PlayMode.EMBEDDED_VIDEO)
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.startImuStreamButton.setOnClickListener {
|
binding.buttons.startImuStreamButton.setOnClickListener {
|
||||||
newPlayer.playWhenReady = true
|
newPlayer.playWhenReady = true
|
||||||
newPlayer.playStream("imu", PlayMode.EMBEDDED_VIDEO)
|
newPlayer.playStream("imu", PlayMode.EMBEDDED_VIDEO)
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.startPortraitStreamButton.setOnClickListener {
|
binding.buttons.startPortraitStreamButton.setOnClickListener {
|
||||||
newPlayer.playWhenReady = true
|
newPlayer.playWhenReady = true
|
||||||
newPlayer.playStream("portrait", PlayMode.EMBEDDED_VIDEO)
|
newPlayer.playStream("portrait", PlayMode.EMBEDDED_VIDEO)
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.startYtTestVideoButton.setOnClickListener {
|
binding.buttons.startYtTestVideoButton.setOnClickListener {
|
||||||
newPlayer.playWhenReady = true
|
newPlayer.playWhenReady = true
|
||||||
newPlayer.playStream("yt_test", PlayMode.EMBEDDED_VIDEO)
|
newPlayer.playStream("yt_test", PlayMode.EMBEDDED_VIDEO)
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.add6502StreamButton.setOnClickListener {
|
binding.buttons.add6502StreamButton.setOnClickListener {
|
||||||
newPlayer.addToPlaylist("6502")
|
newPlayer.addToPlaylist("6502")
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.addImuStreamButton.setOnClickListener {
|
binding.buttons.addImuStreamButton.setOnClickListener {
|
||||||
newPlayer.addToPlaylist("imu")
|
newPlayer.addToPlaylist("imu")
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.addPortraitStreamButton.setOnClickListener {
|
binding.buttons.addPortraitStreamButton.setOnClickListener {
|
||||||
newPlayer.addToPlaylist("portrait")
|
newPlayer.addToPlaylist("portrait")
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.addYtTestVideoButton.setOnClickListener {
|
binding.buttons.addYtTestVideoButton.setOnClickListener {
|
||||||
newPlayer.addToPlaylist("yt_test")
|
newPlayer.addToPlaylist("yt_test")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
binding.buttons.listenModeButton.setOnClickListener {
|
||||||
|
newPlayer.playBackMode.update {
|
||||||
|
PlayMode.FULLSCREEN_AUDIO
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.buttons.pipModeButton.setOnClickListener {
|
||||||
|
newPlayer.playBackMode.update {
|
||||||
|
PlayMode.PIP
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
newPlayerViewModel.newPlayer = newPlayer
|
newPlayerViewModel.newPlayer = newPlayer
|
||||||
newPlayerViewModel.contentFitMode = ContentScale.FIT_INSIDE
|
newPlayerViewModel.contentFitMode = ContentScale.FIT_INSIDE
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:autoMirrored="true" android:height="24dp" android:viewportHeight="960" android:viewportWidth="960" android:width="24dp">
|
||||||
|
|
||||||
|
<path android:fillColor="#e8eaed" android:pathData="M360,840L200,840q-33,0 -56.5,-23.5T120,760v-280q0,-75 28.5,-140.5t77,-114q48.5,-48.5 114,-77T480,120q75,0 140.5,28.5t114,77q48.5,48.5 77,114T840,480v280q0,33 -23.5,56.5T760,840L600,840v-320h160v-40q0,-117 -81.5,-198.5T480,200q-117,0 -198.5,81.5T200,480v40h160v320ZM280,600h-80v160h80v-160ZM680,600v160h80v-160h-80ZM280,600h-80,80ZM680,600h80,-80Z"/>
|
||||||
|
|
||||||
|
</vector>
|
|
@ -0,0 +1,5 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:autoMirrored="true" android:height="24dp" android:viewportHeight="960" android:viewportWidth="960" android:width="24dp">
|
||||||
|
|
||||||
|
<path android:fillColor="#e8eaed" android:pathData="M160,800q-33,0 -56.5,-23.5T80,720v-480q0,-33 23.5,-56.5T160,160h640q33,0 56.5,23.5T880,240v480q0,33 -23.5,56.5T800,800L160,800ZM160,720h640v-480L160,240v480ZM160,720v-480,480ZM440,520h320v-240L440,280v240ZM520,440v-80h160v80L520,440Z"/>
|
||||||
|
|
||||||
|
</vector>
|
|
@ -73,7 +73,11 @@
|
||||||
app:layout_constraintStart_toEndOf="@id/embedded_player_layout"
|
app:layout_constraintStart_toEndOf="@id/embedded_player_layout"
|
||||||
app:layout_constraintTop_toTopOf="parent">
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
<include layout="@layout/buttons"/>
|
<include
|
||||||
|
android:id="@+id/buttons"
|
||||||
|
layout="@layout/buttons" />
|
||||||
|
|
||||||
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -40,14 +40,13 @@
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/embedded_player_layout"
|
android:id="@+id/embedded_player_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="wrap_content"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/buttons_layout"
|
app:layout_constraintBottom_toTopOf="@+id/buttons_layout"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintHorizontal_bias="0.0"
|
app:layout_constraintHorizontal_bias="0.0"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:layout_constraintVertical_bias="0.0"
|
app:layout_constraintVertical_bias="0.0">
|
||||||
app:layout_constraintVertical_weight="1">
|
|
||||||
|
|
||||||
<net.newpipe.newplayer.VideoPlayerView
|
<net.newpipe.newplayer.VideoPlayerView
|
||||||
android:id="@+id/embedded_player"
|
android:id="@+id/embedded_player"
|
||||||
|
@ -72,7 +71,9 @@
|
||||||
app:layout_constraintTop_toBottomOf="@id/embedded_player_layout"
|
app:layout_constraintTop_toBottomOf="@id/embedded_player_layout"
|
||||||
app:layout_constraintVertical_weight="1">
|
app:layout_constraintVertical_weight="1">
|
||||||
|
|
||||||
<include layout="@layout/buttons"/>
|
<include
|
||||||
|
android:id="@+id/buttons"
|
||||||
|
layout="@layout/buttons"/>
|
||||||
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
|
|
|
@ -1,69 +1,90 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<LinearLayout android:layout_height="wrap_content"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:orientation="vertical"
|
android:layout_height="wrap_content"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/listen_mode_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:src="@drawable/headphones"
|
||||||
|
android:contentDescription="Headphone mode" />
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/pip_mode_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:src="@drawable/pip"
|
||||||
|
android:contentDescription="Picture in Picture mode" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/start_6502_stream_button"
|
android:id="@+id/start_6502_stream_button"
|
||||||
android:layout_gravity="center"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
android:text="Start 6502 Stream" />
|
android:text="Start 6502 Stream" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/start_imu_stream_button"
|
android:id="@+id/start_imu_stream_button"
|
||||||
android:layout_gravity="center"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
android:text="Start IMU Stream" />
|
android:text="Start IMU Stream" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/start_portrait_stream_button"
|
android:id="@+id/start_portrait_stream_button"
|
||||||
android:layout_gravity="center"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
android:text="Start Portrait Stream" />
|
android:text="Start Portrait Stream" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/start_yt_test_video_button"
|
android:id="@+id/start_yt_test_video_button"
|
||||||
android:layout_gravity="center"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
android:text="Start Yt Test Video" />
|
android:text="Start Yt Test Video" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:backgroundTint="@color/material_dynamic_primary50"
|
|
||||||
android:id="@+id/add_6502_stream_button"
|
android:id="@+id/add_6502_stream_button"
|
||||||
android:layout_gravity="center"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:backgroundTint="@color/material_dynamic_primary50"
|
||||||
android:text="Append 6502 Stream" />
|
android:text="Append 6502 Stream" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:backgroundTint="@color/material_dynamic_primary50"
|
|
||||||
android:id="@+id/add_imu_stream_button"
|
android:id="@+id/add_imu_stream_button"
|
||||||
android:layout_gravity="center"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:backgroundTint="@color/material_dynamic_primary50"
|
||||||
android:text="Append IMU Stream" />
|
android:text="Append IMU Stream" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:backgroundTint="@color/material_dynamic_primary50"
|
|
||||||
android:id="@+id/add_portrait_stream_button"
|
android:id="@+id/add_portrait_stream_button"
|
||||||
android:layout_gravity="center"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:backgroundTint="@color/material_dynamic_primary50"
|
||||||
android:text="Append Portrait Stream" />
|
android:text="Append Portrait Stream" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:backgroundTint="@color/material_dynamic_primary50"
|
|
||||||
android:id="@+id/add_yt_test_video_button"
|
android:id="@+id/add_yt_test_video_button"
|
||||||
android:layout_gravity="center"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:backgroundTint="@color/material_dynamic_primary50"
|
||||||
android:text="Add Yt Test Video" />
|
android:text="Add Yt Test Video" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
Loading…
Reference in New Issue