如何用jmf播放音乐
答案:1 悬赏:0 手机版
解决时间 2021-02-09 02:12
- 提问者网友:佞臣
- 2021-02-08 17:00
如何用jmf播放音乐
最佳答案
- 五星知识达人网友:执傲
- 2021-02-08 18:34
import java.io.*;
import javax.media.*;
public class jmf {
Player player = null;
public jmf() {
try {
player = Manager.createPlayer(new MediaLocator("file:"
+ getFilePath("")+ "歌词里的那个谁.mp3"));
player.getDuration();
player.prefetch();
player.start();
} catch (NoPlayerException e2) {
} catch (IOException e3) {}
}
public String getFilePath(String filename) {
String filePath = "";
try {
filePath = this.getClass().getResource(".").getPath()+ filename;
filePath = java.net.URLDecoder.decode(filePath, "UTF-8");
} catch (UnsupportedEncodingException ex) {
}
return filePath;
}
public static void main(String af[]) throws IOException {
new jmf();
}
}
import javax.media.*;
public class jmf {
Player player = null;
public jmf() {
try {
player = Manager.createPlayer(new MediaLocator("file:"
+ getFilePath("")+ "歌词里的那个谁.mp3"));
player.getDuration();
player.prefetch();
player.start();
} catch (NoPlayerException e2) {
} catch (IOException e3) {}
}
public String getFilePath(String filename) {
String filePath = "";
try {
filePath = this.getClass().getResource(".").getPath()+ filename;
filePath = java.net.URLDecoder.decode(filePath, "UTF-8");
} catch (UnsupportedEncodingException ex) {
}
return filePath;
}
public static void main(String af[]) throws IOException {
new jmf();
}
}
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯