Fixed for android and added some peformance changes for android

This commit is contained in:
Alex Kim
2024-12-07 18:11:41 +11:00
parent 832a717585
commit ef036cb362
2 changed files with 7 additions and 4 deletions

View File

@@ -9,9 +9,7 @@ class VlcPlayerModule : Module() {
View(VlcPlayerView::class) { View(VlcPlayerView::class) {
Prop("source") { view: VlcPlayerView, source: Map<String, Any> -> Prop("source") { view: VlcPlayerView, source: Map<String, Any> ->
if (!view.hasSource) { view.setSource(source)
view.setSource(source)
}
} }
Prop("paused") { view: VlcPlayerView, paused: Boolean -> Prop("paused") { view: VlcPlayerView, paused: Boolean ->

View File

@@ -60,6 +60,11 @@ class VlcPlayerView(context: Context, appContext: AppContext) : ExpoView(context
} }
fun setSource(source: Map<String, Any>) { fun setSource(source: Map<String, Any>) {
if (hasSource) {
mediaPlayer?.attachViews(videoLayout, null, false, false)
play()
return
}
val mediaOptions = source["mediaOptions"] as? Map<String, Any> ?: emptyMap() val mediaOptions = source["mediaOptions"] as? Map<String, Any> ?: emptyMap()
val autoplay = source["autoplay"] as? Boolean ?: false val autoplay = source["autoplay"] as? Boolean ?: false
val isNetwork = source["isNetwork"] as? Boolean ?: false val isNetwork = source["isNetwork"] as? Boolean ?: false
@@ -260,7 +265,7 @@ class VlcPlayerView(context: Context, appContext: AppContext) : ExpoView(context
val currentTimeMs = player.time.toInt() val currentTimeMs = player.time.toInt()
val durationMs = player.media?.duration?.toInt() ?: 0 val durationMs = player.media?.duration?.toInt() ?: 0
println("isPlayer Attached: ${videoLayout.isAttachedToWindow}")
if (currentTimeMs >= 0 && currentTimeMs < durationMs) { if (currentTimeMs >= 0 && currentTimeMs < durationMs) {
// Set subtitle URL if available // Set subtitle URL if available
if (player.isPlaying && !isMediaReady) { if (player.isPlaying && !isMediaReady) {