Browse Source

Release desktop mediaPlayer resource (#2239)

* release desktop mediaPlayer

* Update DesktopVideoPlayer.kt

Co-authored-by: 070hm <you@example.com>
Co-authored-by: Igor Demin <igordmn@users.noreply.github.com>
pull/2347/head
Ahmed MJ 2 years ago committed by GitHub
parent
commit
486a53fb14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      experimental/components/VideoPlayer/library/src/desktopMain/kotlin/org/jetbrains/compose/videoplayer/DesktopVideoPlayer.kt

9
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(),

Loading…
Cancel
Save