導航:首頁 > 編程語言 > javamp3wav

javamp3wav

發布時間:2022-04-24 08:13:09

java寫的音樂播放器,只能播放wav文件或者mp3文件,怎麼把程序整合在一起,使播放器既能放wav,也能放mp3

既然是java,那麼就可以下載天天動聽啊!大部分的音樂格式都能放。

❷ java的API哪些類和介面是用來播放音頻文件的,比如說mp3, wav音頻文件之類的

JMF可以 網路去搜 SUN官方有下載
使用也很簡單
File f=new File("e:/a.mp3");
Player p=Manager.createRealizedPlayer(f.toURI().toURL());
p.prefetch();
p.start();

❸ 現在用java編寫一個音樂播放器,但是只能播放MP3 和wav 兩種格式,怎麼才能播放其它格式。謝謝!

需要把相關的編碼器,解碼器集成到裡面去, 估計java本身
集成有mp3,wav的解碼器, 所以你的程序可以播放這兩種格式
的文件, 但是其它格式的解碼器, 需要你自己去找,然後自己
想辦法調用解碼器提供的API來實現!

❹ java播放音頻文件的

我幫你把程序改了一下,你看看吧。
另外,你的music應該建在當前盤的根目錄下,Keepup.wav放在其中,因為你的路徑是/music/Keepup.wav。如果想放在當前項目中,需要把路徑改為music/Keepup.wav(去掉開頭的斜杠),這樣就可以在當前項目下建music目錄放Keepup.wav文件了。你把Keepup.wav放在了src目錄下面,新建了個文件夾叫music,它的路徑應該是src/music/Keepup.wav。
import java.applet.AudioClip;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import javax.swing.JApplet;

public class RR {
RR(){
//URL mus=this.getClass().getResource("/music/Keepup.wav");
URL mus=null;
try {
mus = new File("src/music/Keepup.wav").toURI().toURL();
} catch (MalformedURLException e) {
e.printStackTrace();
}
AudioClip snd =JApplet.newAudioClip(mus);
snd.loop();
}
public static void main(String[] args) {
new RR();
}
}

❺ java 代碼是否可以實現把wav 文件轉成 mp3 的呢

JAVE官方的jar包帶了ffmpeg的exe程序,所以在windows上可以直接使用,
但是如果要在Linux上用就得先把ffmpeg的環境裝好。

Filesource=newFile("source.wav");
Filetarget=newFile("target.mp3");
AudioAttributesaudio=newAudioAttributes();
audio.setCodec("libmp3lame");
audio.setBitRate(newInteger(128000));
audio.setChannels(newInteger(2));
audio.setSamplingRate(newInteger(44100));
EncodingAttributesattrs=newEncodingAttributes();
attrs.setFormat("mp3");
attrs.setAudioAttributes(audio);
Encoderencoder=newEncoder();
encoder.encode(source,target,attrs);

Jar下載地址:http://www.sauronsoftware.it/projects/jave/download.php

❻ java實現 mp3格式轉換wav

❼ java如何實現播放mp3

簡單的實例,代碼如下,純粹JMF載入MP3並播放:
import javax.media.*;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class PlayerMusic implements ControllerListener {// ControllerListener
// 控制事件
private Player player;

private boolean first, loop;

private String path;
private List mp3List;
private int mp3NO = 0;

PlayerMusic(List mp3List) {
this.mp3List = mp3List;
}

public void start() {
try {
player = Manager.createPlayer(new MediaLocator("file://" + mp3List.get(mp3NO)));
} catch (NoPlayerException ex) {
ex.printStackTrace();
System.out.println("不能播放文件");
return;
} catch (IOException ex) {
ex.printStackTrace();
return;
}
if (player == null) {
System.out.println("播放器為空");
return;
}

first = false;
player.addControllerListener(this);
// 提取媒體內容
player.prefetch();

}

public void controllerUpdate(ControllerEvent e) {
// 當媒體播放結束時,循環播放
if (e instanceof EndOfMediaEvent) {
mp3NO++;
if(mp3NO<this.mp3List.size()){
this.start();
}
return;
}

// 當預提取媒體的內容結束
if (e instanceof PrefetchCompleteEvent) {
player.start();
return;
}
// 當實例化後
if (e instanceof RealizeCompleteEvent) {
// pack(); //執行pack()操作
return;
}

}
public static void main(String[] args) {
List mp3List = new ArrayList();
mp3List.add("d://a.mp3");
mp3List.add("d://b.mp3");
mp3List.add("d://c.mp3");
PlayerMusic pm = new PlayerMusic(mp3List);
pm.start();
}
}

❽ 如何把java裡面的mp3格式聲音改成wav格式的

千千靜聽 就可以了
把歌曲放進播放列表中 右鍵點擊要轉化的歌曲 選擇 "轉化格式"
在裡面的 "輸出格式" 選擇 "wave 文件輸出" 就行了
記得修改保存的地址

❾ java能支持播放什麼格式的音頻文件

之前遠標老師說一般不裝插件情況下,jdk自帶類庫只能實現AU,AIFF,WAV,MIDI,RFM等格式的音頻,加了插件後才能實現mp3等。

❿ java如何播放wav文件

建議使用jmf(java media framwork),這樣就能播放mp3等眾多格式的音樂了;去sun官網下一個jmf,安裝好後,把
jmf.jar包引入便可使用,給出例zi代碼:使用方法:構造函數中傳入文件路徑名即可,播放、暫停、繼續、停止等功能均已實現。

/*************************************************
* Subclass: MusicPlay
*************************************************/
public class MusicPlay implements Runnable {
private Time zeroTime = new Time(0);
private Player player;
private boolean isloop = false;

/*************************************************
* Function: MusicPlay Description: constructor, load the music file and
* get ready for play Called By: MultiMedia()
*************************************************/
// 實例化各個參數 filename 為文件名,可為絕對路徑
public MusicPlay(String filename) {
File file = new File(filename);
try {
player = Manager.createRealizedPlayer(file.toURI().toURL());
player.addControllerListener(new ControllListener());
} catch (NoPlayerException e) {
e.printStackTrace();
} catch (CannotRealizeException e) {
e.printStackTrace();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}

/*************************************************
* Function: isRunning Description: test if this music is playing Called
* By:
*************************************************/
public boolean isRunning() {
return player.getState() == Player.Started;
}

/*************************************************
* Function: play Description: play the music for once Called By:
* resumeAll()
*************************************************/
// 只播放一次
public void play() {
if (!turnOff)
player.start();
}

/*************************************************
* Function: replay Description: replay the music Called By: musics that
* will be played many times will invoke this methed
*************************************************/
// 再播放一次
public void replay() {
if (turnOff)
return;

if (player.getState() == Controller.Prefetched)
player.setMediaTime(zeroTime);
player.start();
}

/*************************************************
* Function: stop Description: stop this music Called By: stopAll() of
* upper class,suspendAll() of upper
* class,BackroundForMenuPanel,GameOverPanel
*************************************************/
public void stop() {
player.stop();
}

/*************************************************
* Function: close Description: dispose the music Called By: closeAll()
* of super class
*************************************************/
public void close() {
player.stop();
player.close();
}

/*************************************************
* Function: loop Description: make the music played repetitiously
* Called By: music that will repetitious play
*************************************************/
// 循環播放
public void loop() {
if (turnOff)
return;

isloop = true;
player.prefetch();
replay();
}

/*************************************************
* Function: run Description: trig this music Called By: Override method
*************************************************/
@Override
public void run() {
loop();
}

/*************************************************
* Subclass: ControllListener Description: listener for playing and
* implement playing repetitiously
*************************************************/
// 通過對播放進度的監聽,實現循環播放
private class ControllListener implements ControllerListener {

public void controllerUpdate(ControllerEvent e) {
if (e instanceof EndOfMediaEvent) {
if (isloop) {
player.setMediaTime(new Time(0));
player.start();
}
}
}
}

}

閱讀全文

與javamp3wav相關的資料

熱點內容
linux分區讀取 瀏覽:794
單片機液晶顯示屏出現雪花 瀏覽:890
解壓器用哪個好一點 瀏覽:771
什麼app看小說全免費 瀏覽:503
sha和ras加密 瀏覽:823
韓順平php視頻筆記 瀏覽:636
阿里雲ecs伺服器如何設置自動重啟 瀏覽:596
三星電視怎麼卸掉app 瀏覽:317
如何將pdf轉換成docx文件 瀏覽:32
dos命令批量改名 瀏覽:376
centosphp環境包 瀏覽:601
mfipdf 瀏覽:534
電腦解壓後電腦藍屏 瀏覽:295
外網訪問內網伺服器如何在路由器設置 瀏覽:856
2014統計年鑒pdf 瀏覽:434
linuxoracle用戶密碼 瀏覽:757
股票交易pdf 瀏覽:898
p2papp源碼 瀏覽:308
記錄睡眠軟體app哪個好用 瀏覽:140
液壓助力車壓縮比 瀏覽:217