谁给我做一个用java编写的MP3程序,谢谢了
展开全部
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.media.bean.playerbean.MediaPlayer; //必须下载 jmf 媒体播放包
public class player extends Applet implements ActionListener {
Button b1, b2;
MediaPlayer player;
public void init() {
player = new MediaPlayer();
setLayout(new FlowLayout());
try{
player.setMediaLocation("file:/F:\\音乐\\mp3\\黑白配.mp3");// <<file:/>>不能删除 音频文件路径
} catch (Exception e) {
System.out.println("文件不存在");
}
b1 = new Button("播放");
b2 = new Button("停止");
add(b1);
add(b2);
b1.addActionListener(this);
b2.addActionListener(this);
setSize(200, 200);
setVisible(true);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == b1) {
player.start();
} else if (e.getSource() == b2) {
player.stop();
System.out.println(player.getMediaTime().getSeconds());
}
}
}
import java.awt.event.*;
import java.applet.*;
import javax.media.bean.playerbean.MediaPlayer; //必须下载 jmf 媒体播放包
public class player extends Applet implements ActionListener {
Button b1, b2;
MediaPlayer player;
public void init() {
player = new MediaPlayer();
setLayout(new FlowLayout());
try{
player.setMediaLocation("file:/F:\\音乐\\mp3\\黑白配.mp3");// <<file:/>>不能删除 音频文件路径
} catch (Exception e) {
System.out.println("文件不存在");
}
b1 = new Button("播放");
b2 = new Button("停止");
add(b1);
add(b2);
b1.addActionListener(this);
b2.addActionListener(this);
setSize(200, 200);
setVisible(true);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == b1) {
player.start();
} else if (e.getSource() == b2) {
player.stop();
System.out.println(player.getMediaTime().getSeconds());
}
}
}
追问
不用jmf包不行么?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |