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 ();