Add the following classes from the ORG.VIDEOLAN.VLC package in the vlc-android:
Aout.java
Bitmapcache.java
Eventmanager.java
Libvlc.java
Libvlcexception.java
Trackinfo.java
Util.java
Vlcapplication.java
Weakhandler.java
3. Add the source code to the Libs under the armeabi-v7a (if the device is ARM6 or below, is the Armeabi) folder added under the Libs of Android project
URI = "RTSP://217.146.95.166:554/LIVE/CH6BQVGA.3GP" is the one I find on the Internet. RTSP Streaming Address
The main parts are:
A. MLIBVLC = Libvlc.getinstance (); Used to get an instance of MLIBVLC, where LIBVLC is initialized, android:name= "Org.videolan.vlc.VLCApplication" is added in Androidmanifest.xml When the program starts, it calls Vlcapplication to generate the instance without causing libvlc.getinstance () to fail.
B.mlibvlc.readmedia (URI, false); After invoking this sentence, if the URI address is available, the streaming media starts to load, and plays, and does not require mlibvlc.play ().
C.mlibvlc.attachsurface (Msurfaceholder.getsurface (), mainactivity.this,width,height); Call this sentence when the video does not display, the interface suddenly exited, is because there is no add: public void setsurfacesize (int width, int height, int sar_num, int sar_den) This function (when I compile the source code android_abi=armeabi-v7a , Android_abi sets different parameters for this function), which is called in the Libvlcjni.c jni_setandroidsurfacesize function to set the Surfaceview size.
If you need hardware decoding, you need to add the following methods:
[Java] view plaincopy
-
private void  ENABLEIOMX ( boolean  ENABLEIOMX) {
Sharedpreferences p = preferencemanager.getdefaultsharedpreferences (Vlcapplication.getappcontext ());
Editor e = P.edit ();
E.putboolean ("Enable_iomx", ENABLEIOMX);
Libvlc.restart ();
}
Set Sharedpreferences key "Enable_iomx" to True, because LIBVLCJNI.C is libvlc_media_t *new_media through functions (jlong instance, jnienv *env , Jobject thiz, jstring filelocation, bool NOOMX, BOOL Novideo) call Libvlc.java () in Java code USEIOMX to get the value of "ENABLE_IOMX", Then determine whether to decode with hardware.
The error that occurs during debugging is because of the string Android_abi = Properties.getproperty ("Android_abi") in Util.java, and the call property "Android_abi" The value returned is NULL, which occurs mainly in libvlc.getinstance (); When you decide for android_abi==null, you can choose to assign a value of "armeabi-v7a" or "Armeabi" according to your device.
[HTML] view Plaincopy
Meventmanger = EventManager . getinstance ();
Meventmanger.addhandler (Meventhandler);
is used to add playback events, when the playback video appears play,stop,pause and other status, will receive.
VLC for Android use