You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: recover video playback after composition removal (#203)
Make VideoMetadata observable by Compose: convert the data class to a
regular class whose fields are backed by mutableStateOf, so in-place
mutations of width/height/etc. trigger recomposition. copy(), equals(),
hashCode() and toString() are preserved manually for API compatibility.
On Android, re-attach the ExoPlayer to the PlayerView inside the
AndroidView update callback when playerView.player is null. onReset
nulls the player and calls onPause() for LazyList recycling; without a
re-attach on update, the surface stayed blank when scrolling a recycled
item back into view.
Copy file name to clipboardExpand all lines: mediaplayer/src/androidMain/kotlin/io/github/kdroidfilter/composemediaplayer/VideoPlayerSurface.android.kt
+9-6Lines changed: 9 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -207,12 +207,15 @@ private fun VideoPlayerContent(
207
207
},
208
208
update = { playerView ->
209
209
try {
210
-
// Verify that the player is still valid before updating
211
-
if (playerState isDefaultVideoPlayerState&&
212
-
playerState.exoPlayer !=null&&
213
-
playerView.player !=null
214
-
) {
215
-
// Update the resize mode when contentScale changes
210
+
val state = playerState as?DefaultVideoPlayerState
211
+
if (state?.exoPlayer !=null) {
212
+
// Re-attach after LazyList recycle: onReset nulls playerView.player
213
+
// and calls onPause(). Without this, the surface stays blank until
0 commit comments