Obtain the video playback status in vlc_android.

Source: Internet
Author: User

The status of videos in VLC is as follows:

    int libvlc_NothingSpecial=0;    int libvlc_Opening=1;    int libvlc_Buffering=2;    int libvlc_Playing=3;    int libvlc_Paused=4;    int libvlc_Stopped=5;    int libvlc_Ended=6;    int libvlc_Error=7;

Libvlc. Java in vlc_android does not obtain these interfaces. There is only one

    /**     * Returns true if any media is playing     */    public native boolean isPlaying();

But what is playing? In the VLC source code, you can see

(state == libvlc_Opening) || (state == libvlc_Buffering) ||           (state == libvlc_Playing)

The three statuses are isplaying.

Sometimes our requirements are more detailed. If we want to add a progressbar before playing the online video, the progressbar will be canceled when the video starts to play. In this case, we must know when libvlc_playing will appear.

To get more subdivided states, you only need to modify libvlcjni. C by yourself.

jint Java_org_videolan_vlc_LibVLC_getState(JNIEnv *env, jobject thiz){    libvlc_media_list_player_t *mp = getMediaListPlayer(env, thiz);    if (mp){        libvlc_state_t state=libvlc_media_list_player_get_state(mp);        return (jint)state;    }    else        return -1;}

Add the native function to libvlc. Java:

    public native int getState();

Compile the VLC Android source code to get libvlcjni. so. Just add it to your project.

Example,

    
Load (URL); loadingdialog = progressdialog. Show (this, "", "loading... ", False, true); New thread (New runnable () {@ override public void run () {While (true) {try {thread. sleep (1000); log. D (TAG, "Progress Dialog ():" + mlibvlc. getstate (); If (mlibvlc! = NULL & mlibvlc. getstate () = libvlc_state.libvlc_playing) {loadingdialog. dismiss (); break;} catch (interruptedexception e) {e. printstacktrace ();}}}}). start ();

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.