Playing an audio file on JButton press?

梦想的初衷 提交于 2019-12-18 09:28:16

问题


I've looked on Google for a while, searching how to play audio files, and most of the sources I found were with using java.applet.*, but I am trying to look for a way I can put it inside my actionPerformed() method.

public void actionPerformed(ActionEvent event) {
    if(event.getActionCommand().equals("Play")){
        //Short Audio File Playing Here
    }
}

回答1:


See the JavaSound info. page for the "Playing a Clip" section.




回答2:


You may learn and use javax.sound API. Have a look at tutorial - Playing Back Audio.



来源:https://stackoverflow.com/questions/8997363/playing-an-audio-file-on-jbutton-press

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!