Esempio n. 1
0
  private RendererState getPrimaryState() {
    libvlc_state_t state = renderer.getVLCJPlayer().getMediaState();

    if (state == null) {
      return RendererState.ERROR;
    }

    switch (state) {
      case libvlc_Buffering:
        return RendererState.BUFFERING;
      case libvlc_Ended:
        return RendererState.STOPPED;
      case libvlc_Error:
        return RendererState.ERROR;
      case libvlc_NothingSpecial:
        return RendererState.STOPPED;
      case libvlc_Opening:
        return RendererState.BUFFERING;
      case libvlc_Paused:
        return RendererState.PAUSED;
      case libvlc_Playing:
        return RendererState.PLAYING;
      case libvlc_Stopped:
        return RendererState.STOPPED;
    }

    return RendererState.STOPPED;
  }
Esempio n. 2
0
 @Override
 public void playing(MediaPlayer mediaPlayer) {
   renderer.setState(RendererState.PLAYING);
   long position = getSeekPosition();
   if (position > 0) {
     mediaPlayer.setTime(position);
   }
 }
Esempio n. 3
0
 @Override
 public void finished(MediaPlayer mediaPlayer) {
   // Used for YouTube videos
   List<String> subItems = mediaPlayer.subItems();
   if (subItems != null && !subItems.isEmpty()) {
     String subItemURI = subItems.get(0);
     mediaPlayer.playMedia(subItemURI);
   } else {
     renderer.setState(RendererState.STOPPED);
   }
 }
Esempio n. 4
0
 @Override
 public void error(MediaPlayer mediaPlayer) {
   renderer.setState(RendererState.ERROR);
   PlayBlock.log(Level.INFO, "Media has encountered an error!");
 }
Esempio n. 5
0
 @Override
 public void stopped(MediaPlayer mediaPlayer) {
   renderer.setState(RendererState.STOPPED);
 }
Esempio n. 6
0
 @Override
 public void paused(MediaPlayer mediaPlayer) {
   renderer.setState(RendererState.PAUSED);
 }
Esempio n. 7
0
 @Override
 public void opening(MediaPlayer mediaPlayer) {
   renderer.setState(getPrimaryState());
 }
Esempio n. 8
0
 @Override
 public void buffering(MediaPlayer mediaPlayer, float newCache) {
   // This would override a PLAYING state
   renderer.setState(getPrimaryState());
 }