title: Playing a media file in a Jframe java
body: <p>I want to play a video inside a Jframe and am attaching it to a jpanel (jPanel1) where it must play. It keeps saying:</p>
  
  <blockquote>
    <p>"Error reading from the source."</p>
  </blockquote>
  
  <p>And I feel that my media URL is right. It's a small MP4 video.</p>
  
  <p>This is my code:</p>
  
  <pre><code>public void Player()  {
  
      try{
          //create a player to play the media specified in the URL
  
  
          Player mediaPlayer = Manager.createRealizedPlayer(new URL("C:\\Users\\Michael\\Downloads\\mike.jar"));
  
          Manager.setHint(Manager.LIGHTWEIGHT_RENDERER, true);
  
          //get the components for the video and the playback controls
          Component video = mediaPlayer.getVisualComponent();
          Component controls = mediaPlayer.getControlPanelComponent();
  
          if ( video != null )
              jPanel1.add( video, BorderLayout.CENTER ); //add video component
          if ( controls != null )
              jPanel1.add( controls, BorderLayout.SOUTH ); //add controls
  
              mediaPlayer.start(); //start playing the media clip
      } //end try
      catch ( NoPlayerException noPlayerException ){
          JOptionPane.showMessageDialog(null, "No media player found");
      } //end catch
      catch ( CannotRealizeException cannotRealizeException ){
          JOptionPane.showMessageDialog(null, "Could not realize media player.");
      } //end catch
      catch ( IOException iOException ){
          JOptionPane.showMessageDialog(null, "Error reading from the source.");
      } //end catch
  </code></pre>