2013-10-05 73 views
1

The project in Eclipse播放使用Java媒体框架

The Eclipse console output

为什么没有它的工作在Java中的WAV文件?我甚至试图测试剪辑是否运行,使用isRuning的方法,我得到的唯一的东西是文件长度和假的作为返回到isRunning方法。

WAV文件我想扮演的是从维基百科WAV文件的文章,对格式表中的第二个文件。我想它格式很好。

+2

不要放图像的文字信息!复制/粘贴**文本**。另外,所示的示例代码与JMF无关 - 它使用Java Sound。请参阅[Java声音信息](http://stackoverflow.com/tags/java-web-start/info)中的** working **示例中的注释,以获取有关您的尝试失败原因的提示。 –

回答

0

既然不能真正看到你的代码,我张贴我该怎么做,该代码“负荷”的声音:

AudioInputStream audioPush = null; 

    try { 
     push = AudioSystem.getClip(); 

     URL urlPush = getClass().getResource(
        "path to the file"); 

     audioPush = AudioSystem.getAudioInputStream(urlPush); 

     push.open(audioPush); 

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

} 

然后,你必须发挥它像这样:

push.start(); 

这就是我该怎么做,不知道是否有另一种方式,但这个工程。