title: Java Media Framework - MP3 Issues
body: <p>Im using Windows 7 and can "Java Platform SE Binary" in my sound mixer but yet still no sound seems to play.</p>
  
  <p>My code is:</p>
  
  <pre><code>import javax.media.*;
  import java.io.File;
  import java.io.IOException;
  import java.net.URL;
  import java.net.MalformedURLExc;
  
  public class SimpleAudioPlayer {
  private Player audioPlayer = null;
  
  public SimpleAudioPlayer(URL url) throws IOException, NoPlayerException, 
      CannotRealizeException {
      audioPlayer = Manager.createRealizedPlayer(url);
  }
  
  public SimpleAudioPlayer(File file) throws IOException, NoPlayerException, 
      CannotRealizeException {
      this(file.toURL());
  }
  
  public void play() {
      audioPlayer.start();
  }
  
  public void stop() {
      audioPlayer.stop();
      audioPlayer.close();
  }
  
  public static void main(String[] args) {
      try{
          File audioFile = new File("/t.mp3");
          SimpleAudioPlayer player = new SimpleAudioPlayer(audioFile);
  
          System.out.println();
          System.out.println("-&gt; Playing file '" + 
                             audioFile.getAbsolutePath() + "'");
          System.out.println("   Press the Enter key to exit");
          player.play();
  
          // wait for the user to press Enter to proceed.
          System.in.read();
          System.out.println("-&gt; Exiting");
          player.stop();
      }catch(Exception ex){
          ex.printStackTrace();
      }
  
      System.exit(0);
  
  }
  }
  </code></pre>
  
  <p>I use the Windows Preformance JMF edition. The MP3 im trying to play works fine in VLC/WMP so it cant be the file.</p>
  
  <p>The code also throws no exceptions or error when running, it just doesnt seem to play the sound.</p>
  
  <p>Is there something im missing? Like pulling the sound card? E.g. taking over it so i can play sound out of it?</p>
  
  <p>Im overall aim is to to a MP3 streaming service using RTP/RTSP so any links,advice or tuturiols would be help as im currelnt using <a href="http://www.ibm.com/developerworks/java/tutorials/j-jmf/section2.html" rel="nofollow noreferrer">IBM JMF Tuturiol</a> and <a href="http://java-demos.blogspot.co.uk/2012/11/java-code-to-play-mp3-file.html" rel="nofollow noreferrer">Java Demo</a></p>
  
  <p>Please ask if any more information is needed!</p>
  
  <p>UPDATE-</p>
  
  <p>Downloaded <a href="http://freewavesamples.com/files/Yamaha-SY-35-Clarinet-C5.wav" rel="nofollow noreferrer">WAV FILE</a> and it seemed to play, how can i make MP3s play?</p>
  
  <p>Added formats and tried this code and still the same issue:</p>
  
  <pre><code>import java.io.File;
  import javax.media.Format;
  import javax.media.Manager;
  import javax.media.MediaLocator;
  import javax.media.Player;
  import javax.media.PlugInManager;
  import javax.media.format.AudioFormat;
  
  public class SimpleAudioPlayer {
      public static void main(String[] args) {
  
          Format input1 = new AudioFormat(AudioFormat.MPEGLAYER3);
          Format input2 = new AudioFormat(AudioFormat.MPEG);
  
          Format output = new AudioFormat(AudioFormat.LINEAR);
          PlugInManager.addPlugIn(
              "com.sun.media.codec.audio.mp3.JavaDecoder",
              new Format[]{input1, input2},
              new Format[]{output},
              PlugInManager.CODEC
          );
          try {
              Player player = Manager.createPlayer(new MediaLocator(new File("/t.mp3").toURI().toURL()));
              player.start();
          }
          catch(Exception ex) {
              ex.printStackTrace();
          }
      }
  }
  </code></pre>
  
  <blockquote>
    <p>Unable to handle format: mpeglayer3, 44100.0 Hz, 16-bit, Stereo, LittleEndian, Signed, 16000.0 frame rate, FrameSize=32768 bits
    Failed to realize: com.sun.media.PlaybackEngine@62deaa2e
    Error: Unable to realize com.sun.media.PlaybackEngine@62deaa2e</p>
  </blockquote>
  
  <p>Thats the error!</p>