Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8710255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:34:55+00:00 2026-06-13T04:34:55+00:00

I am trying to load a MP3 file. I have jmf.jar (windows version) in

  • 0

I am trying to load a MP3 file. I have jmf.jar (windows version) in my classpath and am trying to run my class through Eclipse. But I get this error when trying to run.

I downloaded and set this version of JMF from the oracle site:

JMF2.1.1e\lib

I am running with Java 7 from Oracle (through Eclipse)

Error:

 javax.sound.sampled.UnsupportedAudioFileException: 
    could not get audio input stream from input stream  
    at  
 javax.sound.sampled.AudioSystem.getAudioInputStream
    (Unknown Source)
    at
 org.berlin.sound.WaveformDisplaySimulator.main
    (WaveformDisplaySimulator.java:47)

Here is the code:

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;

import javax.media.Codec;
import javax.media.Format;
import javax.media.PlugInManager;
import javax.media.format.AudioFormat;
import javax.sound.sampled.AudioFileFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;


    public static void main(final String[] args) {
        try {

            System.out.println(System.getProperty("java.version"));
            final String MP3 = "com.sun.media.codec.audio.mpa.JavaDecoder";
            Codec mp3 = (Codec) Class.forName(MP3).newInstance();

            final Format input1 = new AudioFormat(AudioFormat.MPEGLAYER3);
            final Format input2 = new AudioFormat(AudioFormat.MPEG);
            final Format output = new AudioFormat(AudioFormat.LINEAR);
            PlugInManager.addPlugIn(
                "com.sun.media.codec.audio.mpa.JavaDecoder",                
                new Format[]{ input1, input2 },
                new Format[]{ output },
                PlugInManager.CODEC
            );

            final AudioFileFormat.Type [] types = AudioSystem.getAudioFileTypes();
            for (final AudioFileFormat.Type t : types) {
                System.out.println("Returning Type : " + t);
            } // End of the for //


            final String PATH = "C:\\Users\\Downloads\\soundcloud2.mp3"; 
            final File file = new File(PATH);
            final AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(new BufferedInputStream(new FileInputStream(file)));

        } catch (final Exception e) {
            e.printStackTrace();
        }
    } // End of the method //
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T04:34:56+00:00Added an answer on June 13, 2026 at 4:34 am

    I never could get the oracle download to work. I ended up downloading a MP3 plugin from this site and then adding the plugin in my classpath. This worked with Eclipse and without.

    http://www.tritonus.org/plugins.html

    Also, I didn’t have to modify my code. I was able to read the mp3 binary data and also stream to output.

    import javax.sound.sampled.AudioFileFormat;
    import javax.sound.sampled.AudioFormat;
    import javax.sound.sampled.AudioInputStream;
    import javax.sound.sampled.AudioSystem;
    import javax.sound.sampled.DataLine;
    import javax.sound.sampled.LineUnavailableException;
    import javax.sound.sampled.SourceDataLine;
    
    http://www.tritonus.org/plugins.html
    
        public static void main(final String [] args) throws Exception {
            System.out.println("Running");        
            System.out.println(System.getProperty("java.version"));        
            final AudioFileFormat.Type [] types = AudioSystem.getAudioFileTypes();
            for (final AudioFileFormat.Type t : types) {
                System.out.println("Returning Type : " + t);
            } // End of the for //                
            final String PATH = "C:\\Users\\bbrown\\Downloads\\swing-hacks-examples-20060109\\Ch10-Audio\\75\\soundcloud2.mp3";             
            final File file = new File(PATH);
            final AudioInputStream in = AudioSystem.getAudioInputStream(new BufferedInputStream(new FileInputStream(file)));
    
            AudioInputStream din = null;
            final AudioFormat baseFormat = in.getFormat();
            final AudioFormat decodedFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED,
                    baseFormat.getSampleRate(),
                    16,
                    baseFormat.getChannels(),
                    baseFormat.getChannels() * 2,
                    baseFormat.getSampleRate(),
                    false);
    
            System.out.println("Channels : " + baseFormat.getChannels());                
            din = AudioSystem.getAudioInputStream(decodedFormat, in);        
            rawplay(decodedFormat, din);
            in.close();       
            System.out.println("Done");
        }    
    
        private static synchronized void rawplay(final AudioFormat targetFormat, final AudioInputStream din) throws IOException, LineUnavailableException {              
            final byte[] data = new byte[4096];
            final SourceDataLine line = getLine(targetFormat);               
            if (line != null) {
                System.out.println("Entering ...");
                // Start
                line.start();
                int nBytesRead = 0, nBytesWritten = 0;
                while (nBytesRead != -1) {
                    nBytesRead = din.read(data, 0, data.length);
                    if (nBytesRead != -1) {
                        nBytesWritten = line.write(data, 0, nBytesRead);
                        System.out.println("... -->" + data[0] + " bytesWritten:" + nBytesWritten);
                    }                                           
                } // End of while //            
                System.out.println("Done ...");
                // Stop
                line.drain();
                line.stop();
                line.close();
                din.close();
            } // End of the if //
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to load a small .txt file into mysql but get all my data
i am trying load file after it created from /stext command line but its
Trying to load a file into python. It's a very big file (1.5Gb), but
Trying to load a local file into a webbrowser control but this does not
I have a problem with out of memory when I'm trying load a few
I trying to load and save setting with this code but when I closing
I have Bass component from http://www.un4seen.com/bass.html . I load mp3 and triying to change
Im trying to open an mp3 in soundpool via an id with load, ive
I'm trying load a 3rd party DLL but I get an error when attempting
Im trying to load a csv file into a datatable using oledb. This is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.