0 Replies Latest reply: Sep 16, 2012 7:19 AM by 962394 RSS

    Problem with JMF

    962394
      Hi,
      I'm trying to play a song with JMF, the song location is in my computer.
      I'm getting an exception of CannotRealizeException.
      I'm king of new programmer with JMF, here is my code :

      import javax.media.CannotRealizeException;
      import javax.media.Manager;
      import javax.media.NoPlayerException;
      import javax.media.Player;
      import java.io.File;
      import java.io.IOException;
      import java.net.URL;

      public class SimpleAudioPlayer {

      private Player audioPLayer;

      public SimpleAudioPlayer(URL url) throws IOException, NoPlayerException, CannotRealizeException {
      audioPLayer = Manager.createRealizedPlayer(url);
      }

      public SimpleAudioPlayer(File file) throws IOException, NoPlayerException, CannotRealizeException {
      this(file.toURI().toURL());
      }

      public void play() {
      audioPLayer.start();
      }

      public void stop() {
      audioPLayer.stop();
      audioPLayer.close();
      }
      public static void main(String[] args) {

      try {
      File file = new File("C://Users//Or//Downloads//Songs//a.mp3") ;
      SimpleAudioPlayer simpleAudioPlayer = null;
      simpleAudioPlayer = new SimpleAudioPlayer(file);
      simpleAudioPlayer.play();
      } catch (IOException e) {
      e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
      } catch (NoPlayerException e) {
      e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
      } catch (CannotRealizeException e) {
      e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
      }

      }
      }

      I have a song with a.mp3 name at this location, and i dont know what is the reason i'm gettting this exception.
      Hope that someone can help me..
      Thanks,
      Or.