2017-08-01 85 views
3

我對http視頻流使用了libvlc(de.mrmaffen:vlc-android-sdk:1.0.6)庫。一切工作正常只是一個問題。如何使用libvlc在surfaceView上顯示流視頻的進度條?

我在我的playmovie()函數調用之前使用了progress-bar,並使用libvlc.isPlaying()布爾函數停止進度條,因此此時我的猜測是視頻被加載,我們將停止進度條。

如何獲得準確的時間緩衝視頻和流開始停止進度條?

回答

0

您需要實現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(); 
相關問題