diff --git a/components/VideoPlayer/common/src/desktopMain/kotlin/org/jetbrains/compose/videoplayer/DesktopVideoPlayer.kt b/components/VideoPlayer/common/src/desktopMain/kotlin/org/jetbrains/compose/videoplayer/DesktopVideoPlayer.kt index 26199f5b47..fec7134aa2 100644 --- a/components/VideoPlayer/common/src/desktopMain/kotlin/org/jetbrains/compose/videoplayer/DesktopVideoPlayer.kt +++ b/components/VideoPlayer/common/src/desktopMain/kotlin/org/jetbrains/compose/videoplayer/DesktopVideoPlayer.kt @@ -1,7 +1,11 @@ package org.jetbrains.compose.videoplayer - + +import androidx.compose.desktop.SwingPanel +import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.runtime.Composable -import javax.swing.JFrame +import androidx.compose.runtime.SideEffect +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color import uk.co.caprica.vlcj.factory.discovery.NativeDiscovery import uk.co.caprica.vlcj.player.component.EmbeddedMediaPlayerComponent @@ -10,13 +14,16 @@ internal actual fun VideoPlayerImpl(url: String, width: Int, height: Int) { println("Video player for $url") NativeDiscovery().discover() // Doesn't work on macOS, see https://github.com/caprica/vlcj/issues/887 for suggestions. - val frame = JFrame() val mediaPlayerComponent = EmbeddedMediaPlayerComponent() - frame.contentPane = mediaPlayerComponent - frame.setLocation(0, 0) - frame.setSize(width,height) - frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) - frame.setVisible(true) - val ok = mediaPlayerComponent.mediaPlayer().media().play(url) - println("play gave $ok") + SideEffect { + val ok = mediaPlayerComponent.mediaPlayer().media().play(url) + println("play gave $ok") + } + return SwingPanel( + background = Color.Transparent, + modifier = Modifier.fillMaxSize(), + componentBlock = { + mediaPlayerComponent + } + ) }