make yt test video work

This commit is contained in:
Christian Schabesberger 2024-09-17 16:05:41 +02:00
parent cde9b1f9ba
commit 120ecae3c0
4 changed files with 98 additions and 8 deletions

View File

@ -75,6 +75,11 @@ class MainActivity : AppCompatActivity() {
newPlayer.playStream("portrait", PlayMode.EMBEDDED_VIDEO) newPlayer.playStream("portrait", PlayMode.EMBEDDED_VIDEO)
} }
binding.startYtTestVideoButton.setOnClickListener {
newPlayer.playWhenReady = true
newPlayer.playStream("yt_test", PlayMode.EMBEDDED_VIDEO)
}
binding.add6502StreamButton.setOnClickListener { binding.add6502StreamButton.setOnClickListener {
newPlayer.addToPlaylist("6502") newPlayer.addToPlaylist("6502")
} }
@ -87,6 +92,10 @@ class MainActivity : AppCompatActivity() {
newPlayer.addToPlaylist("portrait") newPlayer.addToPlaylist("portrait")
} }
binding.addYtTestVideoButton.setOnClickListener {
newPlayer.addToPlaylist("yt_test")
}
videoPlayerViewModel.newPlayer = newPlayer videoPlayerViewModel.newPlayer = newPlayer
videoPlayerViewModel.contentFitMode = ContentScale.FIT_INSIDE videoPlayerViewModel.contentFitMode = ContentScale.FIT_INSIDE

View File

@ -59,6 +59,16 @@ class TestMediaRepository(val context: Context) : MediaRepository {
) )
.build() .build()
"yt_test" -> MediaMetadata.Builder()
.setTitle(context.getString(R.string.yt_test_title))
.setArtist(context.getString(R.string.yt_test_channel))
.setArtworkUri(null)
.setDurationMs(
context.resources.getInteger(R.integer.yt_test_length).toLong() * 1000L
)
.build()
else -> throw Exception("Unknown stream: $item") else -> throw Exception("Unknown stream: $item")
} }
@ -90,7 +100,7 @@ class TestMediaRepository(val context: Context) : MediaRepository {
streamUri = Uri.parse(context.getString(R.string.ccc_imu_1080_mp4)), streamUri = Uri.parse(context.getString(R.string.ccc_imu_1080_mp4)),
mimeType = null, mimeType = null,
streamType = StreamType.AUDIO_AND_VIDEO, streamType = StreamType.AUDIO_AND_VIDEO,
language = "Deutsch", language = null,
identifier = "1080p", identifier = "1080p",
), ),
@ -98,11 +108,51 @@ class TestMediaRepository(val context: Context) : MediaRepository {
streamUri = Uri.parse(context.getString(R.string.ccc_imu_576_mp4)), streamUri = Uri.parse(context.getString(R.string.ccc_imu_576_mp4)),
mimeType = null, mimeType = null,
streamType = StreamType.AUDIO_AND_VIDEO, streamType = StreamType.AUDIO_AND_VIDEO,
language = "Deutsch", language = null,
identifier = "576p" identifier = "576p"
) )
) )
"yt_test" -> listOf(
Stream(
streamUri = Uri.parse(context.getString(R.string.yt_test_video_sd)),
mimeType = null,
streamType = StreamType.VIDEO,
language = null,
identifier = "SD",
),
Stream(
streamUri = Uri.parse(context.getString(R.string.yt_test_video_hd)),
mimeType = null,
streamType = StreamType.VIDEO,
language = null,
identifier = "HD",
),
Stream(
streamUri = Uri.parse(context.getString(R.string.yt_test_video_fullhd)),
mimeType = null,
streamType = StreamType.VIDEO,
language = null,
identifier = "FullHD",
),
Stream(
streamUri = Uri.parse(context.getString(R.string.yt_test_audio_english)),
mimeType = null,
streamType = StreamType.AUDIO,
language = "English",
identifier = "default audio",
),
Stream(
streamUri = Uri.parse(context.getString(R.string.yt_test_audio_spanish)),
mimeType = null,
streamType = StreamType.AUDIO,
language = "Spanish",
identifier = "default audio",
)
)
else -> throw Exception("Unknown item: $item") else -> throw Exception("Unknown item: $item")
} }
@ -125,6 +175,7 @@ class TestMediaRepository(val context: Context) : MediaRepository {
"6502" -> context.getString(R.string.ccc_6502_preview_thumbnails) "6502" -> context.getString(R.string.ccc_6502_preview_thumbnails)
"imu" -> context.getString(R.string.ccc_imu_preview_thumbnails) "imu" -> context.getString(R.string.ccc_imu_preview_thumbnails)
"portrait" -> null "portrait" -> null
"ty_test" -> null
else -> throw Exception("Unknown stream: $item") else -> throw Exception("Unknown stream: $item")
} }

View File

@ -100,6 +100,13 @@
android:layout_gravity="center" android:layout_gravity="center"
android:text="Start Portrait Stream" /> android:text="Start Portrait Stream" />
<Button
android:id="@+id/start_yt_test_video_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Start Yt Test Video" />
<Button <Button
android:id="@+id/add_6502_stream_button" android:id="@+id/add_6502_stream_button"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -124,6 +131,14 @@
android:backgroundTint="@color/material_dynamic_primary50" android:backgroundTint="@color/material_dynamic_primary50"
android:text="Append Portrait Stream" /> android:text="Append Portrait Stream" />
<Button
android:id="@+id/add_yt_test_video_button"
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" />
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>

View File

@ -99,29 +99,44 @@
android:layout_gravity="center" android:layout_gravity="center"
android:text="Start Portrait Stream" /> android:text="Start Portrait Stream" />
<Button
android:id="@+id/start_yt_test_video_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Start Yt Test Video" />
<Button <Button
android:id="@+id/add_6502_stream_button" android:id="@+id/add_6502_stream_button"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:text="Append 6502 Stream" android:backgroundTint="@color/material_dynamic_primary50"
android:backgroundTint="@color/material_dynamic_primary50"/> android:text="Append 6502 Stream" />
<Button <Button
android:id="@+id/add_imu_stream_button" android:id="@+id/add_imu_stream_button"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:text="Append IMU Stream" android:backgroundTint="@color/material_dynamic_primary50"
android:backgroundTint="@color/material_dynamic_primary50"/> android:text="Append IMU Stream" />
<Button <Button
android:id="@+id/add_portrait_stream_button" android:id="@+id/add_portrait_stream_button"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:text="Append Portrait Stream" android:backgroundTint="@color/material_dynamic_primary50"
android:backgroundTint="@color/material_dynamic_primary50"/> android:text="Append Portrait Stream" />
<Button
android:id="@+id/add_yt_test_video_button"
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" />
</LinearLayout> </LinearLayout>