title: VLCJ: Updating the progress bar as the video progresses
body: <p>Please have a look at the following code</p>
  
  <pre><code>import com.sun.jna.Native;
  import uk.co.caprica.vlcj.binding.LibVlc;
  import uk.co.caprica.vlcj.component.EmbeddedMediaPlayerComponent;
  import uk.co.caprica.vlcj.runtime.RuntimeUtil;
  
  import com.sun.jna.NativeLibrary;
  import javax.swing.JFrame;
  import javax.swing.SwingUtilities;
  import javax.swing.*;
  import java.awt.*;
  import java.awt.event.*;
  import javax.media.bean.playerbean.MediaPlayer;
  import uk.co.caprica.vlcj.player.MediaPlayerEventAdapter;
  import uk.co.caprica.vlcj.player.MediaPlayerEventListener;
  
  public class PlayMedia extends JFrame
  {
      private EmbeddedMediaPlayerComponent m;
      private JProgressBar bar;
  
      public PlayMedia()
      {
  
          NativeLibrary.addSearchPath(
        RuntimeUtil.getLibVlcLibraryName(), "c:\\program files\\videolan\\vlc"
      );
      Native.loadLibrary(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class);
  
  
          m = new EmbeddedMediaPlayerComponent();
          m.getMediaPlayer().addMediaPlayerEventListener(new UpdateBar());
  
          bar = new JProgressBar(0,100);
          bar.setStringPainted(true);
  
          getContentPane().add(m);
          getContentPane().add(bar,"South");
  
  
          this.setSize(500,500);
          this.validate();
          this.setLocationRelativeTo(null);
  
          this.setVisible(true);
          this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  
  
           m.getMediaPlayer().playMedia("C:\\Users\\Yohan\\Desktop\\video.avi");   
  
      }
  
      private class UpdateBar extends MediaPlayerEventAdapter
      {
          public void positionChanged(MediaPlayer mp, float pos)
          {
              int value = Math.min(100, Math.round(pos * 100.0f));
              bar.setValue(value);
          }
      }
  
      public static void main(String[]args)
      {
  
  
              SwingUtilities.invokeLater(new Runnable() 
              {
              @Override
                  public void run() 
                  {
                      new PlayMedia();
                  }
              });
  
  
      }
  }
  </code></pre>
  
  <p>In here, video is playing fine, but the progress bar is not getting updated. How to update the progress bar as the video plays? Please help!</p>