-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VideoPlayer issues on macOs #1089
Comments
I embedded the VLC in my Compose Multiplatform app (only for Windows). Wanted to share it here. First, downloaded and installed latest version of the VLC media player (v3.0.18) on the system My case is that I need to play only MPEG-TS files with these abilities:
So, the following is the minimum required .dll files from VLC for the above use case (added
Copied the contents of Then downloaded the UPX program to reduce the size of VLC .dll files (to about 50% of their original size!): cd <compose_project_directory>/assets/windows/vlc/
find -type f -name *.dll | xargs -n1 path/to/upx.exe Then modified the app root build.gradle.kts file to add the compose.desktop {
application {
mainClass = // ...
nativeDistributions {
// ...
appResourcesRootDir = (project.rootDir.toPath() / "assets").toFile()
}
}
} Finally, updated the video player: // ...
val assetsPath = System
.getProperty("compose.application.resources.dir")
?.let(::Path)
?: error("The compose.application.resources.dir is not set. Make sure to execute the app using Gradle tasks named `run...`")
val vlcPath = (assetsPath / "vlc").absolutePathString()
NativeDiscovery(object : NativeDiscoveryStrategy {
override fun discover() = vlcPath
override fun supported() = true
override fun onFound(path: String) = true
override fun onSetPluginPath(path: String) = true
}).discover()
if (isMacOS()) {
CallbackMediaPlayerComponent()
} else {
EmbeddedMediaPlayerComponent()
}
// ... I tried to also do this in Ubuntu with VLC .so files but the app started with the error These are probably related issues: |
It's possible but you need to load more plugins and their helper libs too. Also you need to use Here is some commits I made which make help you to understand what to do. Its still in progress so can't say that it works perfectly (it works bad on arm64 mac but on Linux it's ok). simplex-chat/simplex-chat@116df5c (you don't really need it but in case...) Will send a link to final commit with all the code when I finish. All packaging things for Linux is here: |
That would be great. What more plugins are needed? Could you please provide a little bit more detail on how to do this with newest version of VLC in Linux? Sidenote: Wanted to mention that it is possible to directly show the video in Compose desktop without the need for |
@mahozad, now have time to answer with details. I successfully use VLC on Linux, Windows and mac. As a downside I noticed is that at least on mac videos from iPhone (mov) have no image. It can probably fixed by including one more plugin. Also when my code at some point initialize the player once per run of the app, the thread freezes for 0.5-1-2 seconds. After that every function that use VLC player starts without this delay. This happens on all OSes. Script for the Linux uses AppImage I found on GitHub that works pretty good so I made my work a little easier by just unpacking the AppImage and taking all libs I need from it. In the script I take more libs than needed but you can strip almost all of them if you need just most common formats. In code after line with Maybe everything will work fine without loading this lib, I'm not sure, because I have a lot of changes in logic of loading libs after I discovered inability to have a picture working without loading this lib manually. So, moving to the next step.
When you have pointed the VLC libs to search in their relative directories (by patching the libs) you need to point JNA to search libs in this directories: System.setProperty("jna.library.path", vlcDir.absolutePath) // https://github.com/simplex-chat/simplex-chat/blob/master/apps/multiplatform/desktop/src/jvmMain/kotlin/chat/simplex/desktop/Main.kt#L31C3-L31C62
Before I packed all libs in resources directory to jar and extracted them in runtime but it takes sooooo long time after start to copy them to tmp directory. So I started to pack them differently using compose packager that moves libs to resources directory close to jar files so I don't have to unpack the libs in runtime.
Here I just point compose to directory with symlinks that point to real directory with all libs per $OS-$ARCH. Also I should use the latest jna lib version in order to make something (I don't remember what) working:
Please, ask questions if you have problems in implementing all this in your case. And big-big thank you for giving me a link to non-Swing implementation of video renderer. It saved ton hours of my time and made possible to make inline videos (multiple videos in lazy list) and removed all glitches in videos I had. Sooooo good! |
@avently Thanks for the detailed answer. I also struggled with showing the media picture (it only had audio). Fortunately, VLC is available in Snap format too. So, I used its Snap package instead of the AppImage package (I think both of them, or at least, the Snap version, contain all the required dependencies and libraries). Downloads of various VLC versions for various OSes are also available in https://get.videolan.org/vlc/. Here is what I did for Linux (Ubuntu):
Finally, in the app code, there was no need to manually load libraries.
Glad it was helpful. Thanks goes to DrewCarlson. |
Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks. |
(from #1088 (comment))
theapache64
machine.until I installed VLC:
I think we need to bundle VLC as a part of VideoPlayer.
The separate issue
The text was updated successfully, but these errors were encountered: