B4J Library B4JVlcj (embed VLC MediaPlayer in your program/app)

I am pleased to publish a B4J-wrapper/library of Vlcj (version 3.10.1) which in turn is a Java-wrapper of VLC (VideoLAN). With this wrapper, we can use VLC as a MediaPlayer in B4J.

I guess most of you are already familiar with VLC. Its strength is that it plays (local and in streaming) nearly all available formats/codecs. You might be less familiar with Vlcj - if so, you can find more information about Vlcj here.

In this library, I have wrapped the most important methods, properties and events which are required to create a functional MediaPlayer in B4J. I have tested it on Windows 10 and on my MAC and it works fine on both.

I am attaching the MediaPlayer as a demo-project. I also attach the required B4J-libraries. You also need to install some extra Jars that are necessary to make this work. I also attach the Java-code of the B4J-wrapper.

Vlcj (and VLC) is huge and therefore I have left out some functionality such as subtitles, audio-tracks, embedding logos, video-adjustments etc. You can add missing functionality by using JavaObject (see the GetFps-method in the demo-project), InLineJava or by modifying the attached Java-sources. Please refer to the API JavaDocs. Should you prefer me to do it for you, please then contact me in PM here in the forum and we can discuss it.

Requirements:
-VLC (VideoLAN) must be installed on the computer.
-You must match the CPU architecture of the Java Virtual Machine and the native LibVLC libraries. If you use a 32-bit JVM you must use a 32-bit release of VLC; if you use a 64-bit JVM you must use a 64-bit release of VLC. You can not mix CPU architectures, it will not work.
-Add the extra jars in your B4J Extra/Additional Library folder. They can be downloaded from here.

How to run the demo-project:
-Add the extra jars (jna-4.1.0, jna-platform-4.1.0, slf4j-api-1.7.10,vlcj-3.10.1) in your B4J Extra/Additional Library folder.
-Add the B4JVlcj and B4JDragToMe libraries in your B4J Extra/Additional Library folder.
-Make sure to refresh the Library-pane in the B4J-IDE and tick the libraries.
-Open the demo-project in B4J and read the code-notes.
-Methods and Properties are explained in the IDE-help (see also next post).

License:
-My B4J-wrapper is free to use and Java source code is attached. I am only enabling users to use Vlcj with my B4J-wrapper (B4JVlcj).
-Vlcj is provided under the terms of the gpl3 license. Check their web-site for further information.

Please remember that creating libraries and maintaining them takes time and so does supporting them. Please consider a donation if you use my free libraries as this will surely help keeping me motivated. Thank you!

A compiled jar of the demo-project can be downloaded from this thread.

Here is video of the demo-app in execution:

Enjoy!
 

Attachments

  • B4JVlcjLib.zip
    13.4 KB · Views: 1,361
  • B4JDragToMeLib.zip
    15.5 KB · Views: 1,152
  • B4JVlccDemo.zip
    5.2 KB · Views: 1,300
  • B4JVlcjJAVAsources.zip
    6.2 KB · Views: 1,106
Last edited:

moster67

Expert
Licensed User
Longtime User
I haven't checked the library with most recent versions of VLC but the error is probably related to what I wrote in the first post of this thread :

[-You must match the CPU architecture of the Java Virtual Machine and the native LibVLC libraries. If you use a 32-bit JVM you must use a 32-bit release of VLC; if you use a 64-bit JVM you must use a 64-bit release of VLC. You can not mix CPU architectures, it will not work.]
 

alas

Member
I am pleased to publish a B4J-wrapper/library of Vlcj (version 3.10.1) which in turn is a Java-wrapper of VLC (VideoLAN). With this wrapper, we can use VLC as a MediaPlayer in B4J.

I guess most of you are already familiar with VLC. Its strength is that it plays (local and in streaming) nearly all available formats/codecs. You might be less familiar with Vlcj - if so, you can find more information about Vlcj here.

In this library, I have wrapped the most important methods, properties and events which are required to create a functional MediaPlayer in B4J. I have tested it on Windows 10 and on my MAC and it works fine on both.

I am attaching the MediaPlayer as a demo-project. I also attach the required B4J-libraries. You also need to install some extra Jars that are necessary to make this work. I also attach the Java-code of the B4J-wrapper.

Vlcj (and VLC) is huge and therefore I have left out some functionality such as subtitles, audio-tracks, embedding logos, video-adjustments etc. You can add missing functionality by using JavaObject (see the GetFps-method in the demo-project), InLineJava or by modifying the attached Java-sources. Please refer to the API JavaDocs. Should you prefer me to do it for you, please then contact me in PM here in the forum and we can discuss it.

Requirements:
-VLC (VideoLAN) must be installed on the computer.
-You must match the CPU architecture of the Java Virtual Machine and the native LibVLC libraries. If you use a 32-bit JVM you must use a 32-bit release of VLC; if you use a 64-bit JVM you must use a 64-bit release of VLC. You can not mix CPU architectures, it will not work.
-Add the extra jars in your B4J Extra/Additional Library folder. They can be downloaded from here.

How to run the demo-project:
-Add the extra jars (jna-4.1.0, jna-platform-4.1.0, slf4j-api-1.7.10,vlcj-3.10.1) in your B4J Extra/Additional Library folder.
-Add the B4JVlcj and B4JDragToMe libraries in your B4J Extra/Additional Library folder.
-Make sure to refresh the Library-pane in the B4J-IDE and tick the libraries.
-Open the demo-project in B4J and read the code-notes.
-Methods and Properties are explained in the IDE-help (see also next post).

License:
-My B4J-wrapper is free to use and Java source code is attached. I am only enabling users to use Vlcj with my B4J-wrapper (B4JVlcj).
-Vlcj is provided under the terms of the gpl3 license. Check their web-site for further information.

Please remember that creating libraries and maintaining them takes time and so does supporting them. Please consider a donation if you use my free libraries as this will surely help keeping me motivated. Thank you!

A compiled jar of the demo-project can be downloaded from this thread.

Here is video of the demo-app in execution:

Enjoy!
it is interesting library , but is there away to use it without installing vlc? i found one subject but i dont know how to apply it on your library
embed vlc without installing vlc

thanks
 

moster67

Expert
Licensed User
Longtime User
is there away to use it without installing vlc

Nice idea although the post you cited is quite old (well prior to my wrapper) and it seems some things changed with later versions of VLC.
See here: https://stackoverflow.com/a/38957564/45402

In the very near future, I have no plans to update the wrapper, mostly because I am quite busy. However, I have planned an update so when doing it, I will take your idea into consideration if I can find useful information on how to do it.
 

José J. Aguilar

Expert
Licensed User
Could you post a sample based on B4XPages? I can't find what to send to Videofrm.SetOwner(Main.MainForm) in your class.

Thanks
 

moster67

Expert
Licensed User
Longtime User
I cannot test now, not being at home
In any case, I am not very familiar with B4XPages - I hardly write my own apps these days.
I can try after this weekend after I come home from a short holiday break. If you resolve it in the meantime, please post your findings.
 

giga

Well-Known Member
Licensed User
Longtime User
Great library, I am testing it now. What I am looking for is to able to be play directly from the webcam. VLA can do it by clicking Media then "open capture device" and choose your webcam as the device. It will give you a real-time video capture. Is that method available in this library or how do you add it?

Thank you,
 

peacemaker

Expert
Licensed User
Longtime User
Hi, All

Is there possibility to grab the frames during playing ? Save to a JPG file.
 

moster67

Expert
Licensed User
Longtime User
I am not sure there is such a method, at least in the wrapper there isn't. You need to check the docs of the vlcj-apis (there is a link in the first post). If there is such a method, you may be able to access with Javaobject.

Otherwise you can probably get the frames easily using ffmpeg with jshell.
 

peacemaker

Expert
Licensed User
Longtime User
GridPane1 with "scenegrid" XML layout works good for the resizing.
But how to do the same, but not in the center, just in some container that is controlled by position and dimension (but with auto-resizing of video) ?
 

Star-Dust

Expert
Licensed User
t, you can probably use B4JVlcj to stream your WebCam to a server (although not tested but considering the power of VLC this should be possible).
VLC is just as flexibile as FFmpeg.
Very interesting. How to do using your library?
 

CR95

Member
Licensed User
@moster67 Great library.
I am testing it on Raspberry PI3B with B4J. Video is coming from hard disk connected via USB.
It runs well BUT I have an issue : video is "splitted" and appears in pieces in a jerky way without stopping. The same video appears fluently when launched by "open file/play" directly in VLC.

Do you know this issue and is there a workaround ?
Thanks in advance
 
Top