diff --git a/experimental/components/VideoPlayer/library/src/desktopMain/kotlin/org/jetbrains/compose/videoplayer/DesktopVideoPlayer.kt b/experimental/components/VideoPlayer/library/src/desktopMain/kotlin/org/jetbrains/compose/videoplayer/DesktopVideoPlayer.kt index 6a9b99262a..2c19741c02 100644 --- a/experimental/components/VideoPlayer/library/src/desktopMain/kotlin/org/jetbrains/compose/videoplayer/DesktopVideoPlayer.kt +++ b/experimental/components/VideoPlayer/library/src/desktopMain/kotlin/org/jetbrains/compose/videoplayer/DesktopVideoPlayer.kt @@ -2,6 +2,7 @@ package org.jetbrains.compose.videoplayer import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.runtime.Composable +import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.SideEffect import androidx.compose.runtime.remember import androidx.compose.ui.Modifier @@ -13,7 +14,6 @@ import uk.co.caprica.vlcj.player.component.CallbackMediaPlayerComponent import uk.co.caprica.vlcj.player.component.EmbeddedMediaPlayerComponent import java.util.* - @Composable internal actual fun VideoPlayerImpl(url: String, width: Int, height: Int) { NativeDiscovery().discover() @@ -28,6 +28,13 @@ internal actual fun VideoPlayerImpl(url: String, width: Int, height: Int) { SideEffect { mediaPlayerComponent.mediaPlayer().media().play(url) } + + DisposableEffect(Unit) { + onDispose { + mediaPlayerComponent.mediaPlayer().release() + } + } + return SwingPanel( background = Color.Transparent, modifier = Modifier.fillMaxSize(),