java 里支持什么格式的音频文件?

java 里支持什么格式的音频文件?,第1张

java本身有格式限制

可运行在Internet平台上的音频文件有HTML支持的WMIDI.JAVA支持的AU及RA.

另外试试看WAV格式的音乐文件.

这个不是很清楚..

sound=getAudioClip(getCodeBase(),"歌名.wav")

/**

* 播放音乐

*

* @param mp3Path

* @param repeat

*/

public static void playSound(final String mp3Path, final int repeat) {

new Thread(new Runnable() {

@Override

public void run() {

if (mp3Path.endsWith("mp3")) {

// TODO Auto-generated method stub

MP3Player mp3 = new MP3Player(mp3Path)

int ccc = 0

while (ccc <repeat) {

try {

Thread.sleep(1000)

} catch (InterruptedException e) {

// TODO Auto-generated catch block

e.printStackTrace()

}

ccc++

mp3.play()

}

} else {

try {

// .wav 文件放在java project 下面

//System.getProperty("user.dir") + File.separator+ "ring.wav"

System.out.println(mp3Path)

FileInputStream fileau = new FileInputStream(

mp3Path)

AudioStream as = new AudioStream(fileau)

int ccc = 0

while (ccc <repeat) {

try {

Thread.sleep(1000)

} catch (InterruptedException e) {

// TODO Auto-generated catch block

e.printStackTrace()

}

ccc++

AudioPlayer.player.start(as)

}

} catch (Exception e) {

e.printStackTrace()

}

}

}

}).start()

}

sun audio jar下载 需要自己下载


欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/tougao/11997327.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-20
下一篇 2023-05-20

发表评论

登录后才能评论

评论列表(0条)

保存