|
|
@ -1,7 +1,11 @@ |
|
|
|
package org.jetbrains.compose.videoplayer |
|
|
|
package org.jetbrains.compose.videoplayer |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import androidx.compose.desktop.SwingPanel |
|
|
|
|
|
|
|
import androidx.compose.foundation.layout.fillMaxSize |
|
|
|
import androidx.compose.runtime.Composable |
|
|
|
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.factory.discovery.NativeDiscovery |
|
|
|
import uk.co.caprica.vlcj.player.component.EmbeddedMediaPlayerComponent |
|
|
|
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") |
|
|
|
println("Video player for $url") |
|
|
|
NativeDiscovery().discover() |
|
|
|
NativeDiscovery().discover() |
|
|
|
// Doesn't work on macOS, see https://github.com/caprica/vlcj/issues/887 for suggestions. |
|
|
|
// Doesn't work on macOS, see https://github.com/caprica/vlcj/issues/887 for suggestions. |
|
|
|
val frame = JFrame() |
|
|
|
|
|
|
|
val mediaPlayerComponent = EmbeddedMediaPlayerComponent() |
|
|
|
val mediaPlayerComponent = EmbeddedMediaPlayerComponent() |
|
|
|
frame.contentPane = mediaPlayerComponent |
|
|
|
SideEffect { |
|
|
|
frame.setLocation(0, 0) |
|
|
|
|
|
|
|
frame.setSize(width,height) |
|
|
|
|
|
|
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) |
|
|
|
|
|
|
|
frame.setVisible(true) |
|
|
|
|
|
|
|
val ok = mediaPlayerComponent.mediaPlayer().media().play(url) |
|
|
|
val ok = mediaPlayerComponent.mediaPlayer().media().play(url) |
|
|
|
println("play gave $ok") |
|
|
|
println("play gave $ok") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return SwingPanel( |
|
|
|
|
|
|
|
background = Color.Transparent, |
|
|
|
|
|
|
|
modifier = Modifier.fillMaxSize(), |
|
|
|
|
|
|
|
componentBlock = { |
|
|
|
|
|
|
|
mediaPlayerComponent |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
} |
|
|
|