VLC for Android Use notes

Source: Internet
Author: User

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

  1. private   void  ENABLEIOMX ( boolean  ENABLEIOMX) {  

  2. Sharedpreferences p = preferencemanager.getdefaultsharedpreferences (Vlcapplication.getappcontext ());

  3. Editor e = P.edit ();

  4. E.putboolean ("Enable_iomx", ENABLEIOMX);

  5. Libvlc.restart ();

  6. }

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

    1. Meventmanger  =  EventManager  . getinstance ();

    2. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.