title: Playing a video from an array of vlcj player
body: <p>I am trying to play a video from the lists of MRL provided as a String.</p>
  
  <p>The problem is when I try to run the class, a list of panels shows with button, with only one panel working, but the play button does not work and that of other panels.</p>
  
  <p>Although I intentionally left the stop button out because I have not added action listeners to them.</p>
  
  <p>What I want to achieve is, when I run the class, a single video plays, and when I click on the play button of another video, the current video stops and moves to the next video.</p>
  
  <p>I don't know where I have gone wrong.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>public class MediaPlayer extends JPanel {
  
      //Declares our media player component
      private EmbeddedMediaPlayerComponent[] mediaplayer;
      private String[] mediapath = {""};
      private final String vlcpath = "C:\\Program Files (x86)\\VideoLAN\\VLC";
      private JPanel video_pnl, control_pnl;
      private JButton[] play_btn, stop_btn;
      private int but = 0;
  
      public MediaPlayer(String mediapath[]) {
          this.mediapath = mediapath;
  
          play_btn = new JButton[1];
          stop_btn = new JButton[1];
          mediaplayer = new EmbeddedMediaPlayerComponent[1];
          int increment = 0;
          while (increment &lt; mediapath.length) {
              video_pnl = new JPanel();
              video_pnl.setLayout(new BorderLayout());
              control_pnl = new JPanel();
              control_pnl.setLayout(new FlowLayout(FlowLayout.CENTER));
              for (int i = 0; i &lt; 1; i++) {
  
                  NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(), vlcpath);
                  mediaplayer[i] = new EmbeddedMediaPlayerComponent();
                  play_btn[i] = new JButton("play");
                  stop_btn[i] = new JButton("stop");
  
  
                  video_pnl.add(mediaplayer[i], BorderLayout.CENTER);
  
                  control_pnl.add(play_btn[i]);
                  control_pnl.add(stop_btn[i]);
                  video_pnl.add(control_pnl, BorderLayout.SOUTH);
  
                  Handler handler = new Handler();
                  play_btn[i].addActionListener(handler);
              }
              add(video_pnl);
              increment++;
          }
      }
  
      private class Handler implements ActionListener {
  
          @Override
          public void actionPerformed(ActionEvent e) {
              if(e.getSource() == play_btn){
                  play();
              }
          }
      }
  
      public void play() {
          for (int i = 0; i &lt; mediapath.length; i++) {
              mediaplayer[i].getMediaPlayer().playMedia(mediapath[i]);
          }
      }
  
      public static void main(String[] args) {
          //Declare and initialize local variables
          String[] mediaPath =       {"C:\\\\Users\\\\goldAnthony\\\\Desktop\\\\Videos\\\\Whistle.mp4", "C:\\\\Users\\\\goldAnthony\\\\Desktop\\\\Videos\\\\Beyonce_Hello.mp4",
          "C:\\Users\\goldAnthony\\Desktop\\Videos\\HansRosling_2012S_480p.mp4","C:\\Users\\goldAnthony\\Desktop\\Videos\\oow2010_2.mp4",
          "C:\\Users\\goldAnthony\\Desktop\\Videos\\The_Economic_Environment.mp4"};
  
          //creates instances of the VlcPlayer object, pass the mediaPath and invokes the method "run"
          MediaPlayer mediaplayer = new MediaPlayer(mediaPath);
          JFrame ourframe = new JFrame();
          ourframe.setContentPane(mediaplayer);
          ourframe.setLayout(new GridLayout(5, 1));
          ourframe.setSize(300, 560);
          ourframe.setVisible(true);
          mediaplayer.play();
          ourframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      }
  }
                  control_pnl.add(play_btn[i]);
                  control_pnl.add(stop_btn[i]);
                  video_pnl.add(control_pnl, BorderLayout.SOUTH);
  
                  Handler handler = new Handler();
                  play_btn[i].addActionListener(handler);
              }
              add(video_pnl);
              increment++;
          }
      }
  
      private class Handler implements ActionListener {
  
          @Override
          public void actionPerformed(ActionEvent e) {
              if(e.getSource() == play_btn){
                  play();
              }
          }
      }
  
      public void play() {
          for (int i = 0; i &lt; mediapath.length; i++) {
              mediaplayer[i].getMediaPlayer().playMedia(mediapath[i]);
          }
      }
  
      public static void main(String[] args) {
          //Declare and initialize local variables
          String[] mediaPath =       {"C:\\\\Users\\\\goldAnthony\\\\Desktop\\\\Videos\\\\Whistle.mp4", "C:\\\\Users\\\\goldAnthony\\\\Desktop\\\\Videos\\\\Beyonce_Hello.mp4",
          "C:\\Users\\goldAnthony\\Desktop\\Videos\\HansRosling_2012S_480p.mp4","C:\\Users\\goldAnthony\\Desktop\\Videos\\oow2010_2.mp4",
          "C:\\Users\\goldAnthony\\Desktop\\Videos\\The_Economic_Environment.mp4"};
  
          //creates instances of the VlcPlayer object, pass the mediaPath and invokes the method "run"
          MediaPlayer mediaplayer = new MediaPlayer(mediaPath);
          JFrame ourframe = new JFrame();
          ourframe.setContentPane(mediaplayer);
          ourframe.setLayout(new GridLayout(5, 1));
          ourframe.setSize(300, 560);
          ourframe.setVisible(true);
          mediaplayer.play();
          ourframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      }
  }
  </code></pre>