您需要實現EventListener.Like這樣
LibVLC vlcInstance = new LibVLC(context, new VlcOptions().getDefaultOptions());
org.videolan.libvlc.MediaPlayer player = new org.videolan.libvlc.MediaPlayer(vlcInstance);
player.setEventListener(new org.videolan.libvlc.MediaPlayer.EventListener() {
@Override
public void onEvent(org.videolan.libvlc.MediaPlayer.Event event) {
switch (event.type) {
case org.videolan.libvlc.MediaPlayer.Event.Opening:
//Video Opening
break;
case org.videolan.libvlc.MediaPlayer.Event.Playing:
//Video Playing
break;
case org.videolan.libvlc.MediaPlayer.Event.Buffering:
//Video Buffering
break;
case org.videolan.libvlc.MediaPlayer.Event.Stopped:
//Video Stopped
break;
case org.videolan.libvlc.MediaPlayer.Event.EndReached:
//Video EndReached/Completed
break;
case org.videolan.libvlc.MediaPlayer.Event.EncounteredError:
//Video EncounteredError/Failed
break;
default:
break;
}
}
});
Media media = new Media(vlcInstance, videoUri);
media.addOption(":fullscreen");
media.setHWDecoderEnabled(true, false);
player.setMedia(media);
IVLCVout vlcOut = player.getVLCVout();