title: How to play mp4 video on JPanel?
body: <p>I am using the Xuggle library to play mp4 videos on a JPanel but video loading is taking 3 sec. or more. Do you have some advice how to play video on JPanel or JLabel in the right way?</p>
  
  <p>Is this a good way to show mp4 video? VideoCodec is a Xuggle Codec. This is working but I have a delay of a few seconds.</p>
  
  <pre><code>public void setVideoName(final String videoName) {
      imageAndVideoPanel.removeAll();
      final VideoPanel videoPanel = new VideoPanel();
      videoPanel.setPreferredSize(Const.Dimensions.VIDEO_SIZE);
      videoPanel.setMinimumSize(Const.Dimensions.VIDEO_SIZE);
      videoPanel.setMaximumSize(Const.Dimensions.VIDEO_SIZE);
      imageAndVideoPanel.add(videoPanel);
  
      new Thread(new Runnable() {
          @Override
          public void run() {
              VideoCodec videoCodec =
                      new VideoCodec(videoPanel, videoName + TextsDao.getText("videoFilesExtension"));
          }
      }).start();
  }
  </code></pre>