JMF mp3插件错误

时间:2013-12-20 11:55:17

标签: java

大家好我想尝试在java中开发mp3播放器。我hava安装了jmf,也包括在内 jmfmp3plugin,这是我的代码..

import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;

import javax.media.Manager;
import javax.media.MediaLocator;
import javax.media.NoPlayerException;
import javax.media.Player;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.sound.sampled.FloatControl;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.UnsupportedAudioFileException;
import javax.swing.JFrame;
import javax.swing.JOptionPane;

public class SoundPlayer extends JFrame{
    public void plmusic(){
        try {
            Clip clp = AudioSystem.getClip();
            AudioInputStream is = AudioSystem.getAudioInputStream(new File("1_welcome.wav"));
            clp.open(is);
            FloatControl fc =(FloatControl) clp.getControl(FloatControl.Type.MASTER_GAIN);
            fc.setValue(-50f);
            clp.start();
        } catch (LineUnavailableException e) {

            e.printStackTrace();
        } catch (UnsupportedAudioFileException e) {

            e.printStackTrace();
        } catch (IOException e) {

            e.printStackTrace();
        }
    }
    public static void main(String[] args) {

        try {
            File f = new File("love_is_gone.mp3");
            MediaLocator ml;
            ml = new MediaLocator(f.toURL());
            Player p;
            p = Manager.createPlayer(ml);
            p.start();
        } catch (NoPlayerException e1) {
            JOptionPane.showMessageDialog(null, e1.getMessage());
            e1.printStackTrace();
        } catch (IOException e1) {
            JOptionPane.showMessageDialog(null, e1.getMessage());
            e1.printStackTrace();
        }



    }
}

但我收到此错误

  

无法处理格式:mpeglayer3,44100.0 Hz,16位,立体声,   LittleEndian,签名,16000.0帧速率,FrameSize = 32768位失败   实现:com.sun.media.PlaybackEngine@7129a843错误:无法执行   实现com.sun.media.PlaybackEngine@7129a843

1 个答案:

答案 0 :(得分:0)

根据这个http://www.oracle.com/technetwork/java/javase/formats-138492.html mp3似乎不支持?啊,对不起,你正在使用mp3 -plugin。