Results 1 to 7 of 7
  1. #1
    oror84 is offline Member
    Join Date
    Mar 2012
    Posts
    4
    Rep Power
    0

    Default Problem with JMF

    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 :
    Java 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.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,455
    Rep Power
    20

    Default Re: Problem with JMF

    Have you installed the MP3 Plugin?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    oror84 is offline Member
    Join Date
    Mar 2012
    Posts
    4
    Rep Power
    0

    Default Re: Problem with JMF

    Hi and thank you for your answer.
    I just installed the plugin, and still get the same exception.
    Thanks,
    Or.

  4. #4
    oror84 is offline Member
    Join Date
    Mar 2012
    Posts
    4
    Rep Power
    0

    Default Re: Problem with JMF

    This is the error message :
    "Failed to realize: com.sun.media.PlaybackEngine@2beee406
    Error: Unable to realize com.sun.media.PlaybackEngine@2beee406
    javax.media.CannotRealizeException"

    It happens when i'm trying to use Manager.createRealizedPlayer function with audio or video.

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,455
    Rep Power
    20

    Default Re: Problem with JMF

    Have you tried the same code with another media format, say .SND or .AU?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  6. #6
    kammce's Avatar
    kammce is offline Senior Member
    Join Date
    Dec 2010
    Location
    California
    Posts
    194
    Rep Power
    4

    Default Re: Problem with JMF

    You could always use EasyOgg, and use the media format .ogg. It may scale down the quality but the compression is amazing. MP3s support in the native JRE has not been support for quite a while. That is, the JMF, has not been updated. I tried using it before and ran into a bunch of problems. Pretty much the same situations that you are in.

    When you do EasyOgg, you have to make sure the Audio Codec is "vorbis" to get it to work.
    My API:
    Java Code:
    cat > a.out || cat > main.class

  7. #7
    vamshi072 is offline Member
    Join Date
    Dec 2013
    Posts
    1
    Rep Power
    0

    Exclamation Re: Problem with JMF

    Quote Originally Posted by DarrylBurke View Post
    Have you installed the MP3 Plugin?

    db
    I got this error when i gave an mp3 file as input .

    Unable to handle format: mpegaudio, 48000.0 Hz, 16-bit, Stereo, LittleEndian, Signed, 16000.0 frame rate, FrameSize=32768 bits
    Failed to prefetch: com.sun.media.PlaybackEngine@17115c51
    Error: Unable to prefetch com.sun.media.PlaybackEngine@17115c51

    Error: Unable to prefetch com.sun.media.PlaybackEngine@17115c51

    Unable to handle format: mpegaudio, 48000.0 Hz, 16-bit, Stereo, LittleEndian, Signed, 16000.0 frame rate, FrameSize=32768 bits
    Failed to prefetch: com.sun.media.PlaybackEngine@17115c51


    mp3 player plugin , i opened ur link JMF MP3 Plugin but mp3 player is not present
    please help me out .

Similar Threads

  1. Small problem with problem with Java, C++ parse program.
    By dragstang86 in forum New To Java
    Replies: 4
    Last Post: 10-30-2011, 04:43 AM
  2. Replies: 9
    Last Post: 09-21-2010, 05:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •