Binding FFI of libvlc for Pharo
-
Install VLC 3.x.x
-
In a Pharo 11 image
Metacello new
baseline: 'VLC';
repository: 'github:https://badetitou/Pharo-LibVLC';
load.
You should be able to execute
VLCLibrary uniqueInstance getVersion
If you work on linux, please check that libvlc
and libvlccore
are in your path.
To do so, you can execute whereis libvlc
and whereis libvlccore
.
If the whereis
command return something like:
libvlccore: /usr/lib/libvlccore.so
→ OKlibvlccore:
→ It means you didn't install correctly the libraries, or you used snap.libvlccore: /usr/lib/libvlccore.so.x
→ It means you've installed a specific version of the library. To use it with pharo please create a symbolic link without the ".x" →ln -s /usr/lib/libvlccore.so.x /usr/lib/libvlccore.so
If you used snap to install vlc, the path might be '/snap/vlc/current/usr/lib'
Simply install the last version of VLC and it should work.
vlc := VLCLibrary uniqueInstance createVLCInstance.
"do not use accentuated characters for the path"
media := vlc createMediaFromPath: '/my/file/path.mp3'.
mediaPlayer := VLCLibrary uniqueInstance mediaPlayerNewFromMedia: media.
mediaPlayer play
Or using a media list.
instance := VLCLibrary uniqueInstance createVLCInstance.
media := instance createMediaFromPath: '/home/badetitou/Musique/Coda.mp3'.
mediaList := instance createMediaList.
mediaList addMedia: media.
mediaListPlayer := instance createMediaListPlayer.
mediaListPlayer mediaList: mediaList.
mediaListPlayer mediaList.
mediaListPlayer play