Home » Android » video – How to embed VLC media player to my Android App

video – How to embed VLC media player to my Android App

Posted by: admin April 23, 2020 Leave a comment

Questions:

Is there a way to embed VLC media player to Android Application? I have several issues:

1) I have a video streaming Camera (from RTSP) and I cannot play its stream on my regular videoview panel (Sorry this video cannot be played error). However, I installed the VLC application for Android (beta version) and I was able to play it.
2) My main objective is to port a desktop java application which uses VLC plugin to Android. I want to accomplish this task with minimum effort (I have some time issues).

Another alternative, is there a way to embed codecs used by VLC to my application? Because with my videoview, the result varies according to the format of the video. I can play some other videos streamed through RTSP on my videoview.

I search through internet and found a “libvlc” but also some notes about that libvlc for android is not complete (but those notes belong to a past time, even in stackoverflow).

How to&Answers:

Yes, if you already have the vlc-sdk.7z (libVLC for android), here is the sample project to embedded VLC into your android apps.

If you do not have libVLC, here are the steps to build one. (After “sh compile.sh” finished, “make vlc-sdk.7z” to create the vlc-sdk.7z and unzip to the demo project.

I put the vlc-sdk.7z(only armeabi-v7a is included) here for testing.

Answer:

Maruku has given a great answer.

In addition, if you don’t want to compile libVLC on your own machine, mrmaffen has kindly thrown it up onto maven central. So in your .gradle file include

compile "de.mrmaffen:vlc-android-sdk:1.9.8"

Keep in mind that LibVLC may not be 100% updated because you aren’t compiling the source yourself.

More info can be found here on GitHub

Answer:

2019 sees introduction of a VLCVideoLayout component that greatly simplifies the code required to embed VLC into android.

https://code.videolan.org/videolan/libvlc-android-samples

The libVLC is provided by the official VideoLAN project hosted on BinTray. See the build.gradle files for the link to the Maven repo and the package name/version.

https://code.videolan.org/videolan/libvlc-android-samples/blob/master/build.gradle#L18
https://code.videolan.org/videolan/libvlc-android-samples/blob/master/java_sample/build.gradle#L34

Answer:

Some other answers link to outdated versions, however actual for 2019.03 is LibVlc for all platforms 3.1.8. This is .aar version, you may add it to your project with these instructions and use.

However if all-version is too large(over 70MB), here is armv7 version, and here if x86.

Answer:

The libVLC is provided by the official VideoLAN project hosted on BinTray.
You can directly use the library as a dependency without having to compile it.

add maven url “https://dl.bintray.com/videolan/Android” to your project-level Gradle file as shown below:

allprojects {
 repositories {
      google()
      jcenter()
      maven {
        url "https://maven.google.com";
        }
      maven { url "https://dl.bintray.com/videolan/Android" }
  }
}

and in your app-level Gradle file, add the libVLC dependency

implementation 'org.videolan.android:libvlc-all:<latest-version-here>'

Get the latest libVLC version from the below official VLC GitHub repository.

find the string “libvlcVersion” to get the latest version.

https://github.com/videolan/vlc-android/blob/master/build.gradle#L33

Answer:

Step 1 : install Linux

Step 2 : install ndk and sdk

Step 3 : change your directory path upto compile.sh

then compile.sh run through your Linux terminal and generate apk

Compile – Run – Enjoy