導航:首頁 > 編程語言 > java簡單的音樂播放器

java簡單的音樂播放器

發布時間:2023-12-29 07:41:36

❶ 用java做音視頻播放器

我做過一個MP3的..給你看看.

package music;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import javax.swing.*;
import javax.media.bean.playerbean.*; //這個包要用到JMF

public class MP3 extends JFrame implements Runnable {
public JLabel shijian;

private JSlider sldDiameter;

public MediaPlayer soumd1;

public JButton playSound, loopSound, stopsound;

public JButton tjian, shanc, baocun, qu;

public JPanel jp1, jp2, jp3, jp4;

public JList jl;

int zongmiao=0;

public Vector vector, mingcheng;

boolean fo = false, geshi = false;

JLabel jl1, jl2, sj1, sj2;

JTextField jt1, jt2;

JButton queding, xiugai;

int zong = 0;

int a = 0, b = 0, you = 1,mm=0;

int fenzhong, miaozhong;

public MP3() {
super(「java簡單音樂播放器「);
soumd1 = new MediaPlayer();
Container c = getContentPane();
c.setLayout(new FlowLayout());
mingcheng = new Vector();
jp1 = new JPanel();
shijian = new JLabel();
jp1.add(shijian);
c.add(jp1);
playSound = new JButton(「開始播放「);
loopSound = new JButton(「循環播放「);
stopsound = new JButton(「停止播放「);
jp2 = new JPanel();
jp2.add(playSound);
jp2.add(loopSound);
jp2.add(stopsound);
c.add(jp2);
jp4 = new JPanel();
sj1 = new JLabel();
sj2 = new JLabel();
sldDiameter = new JSlider(SwingConstants.HORIZONTAL, 0, 100, 0);
sldDiameter.setMajorTickSpacing(1);
sldDiameter.setPaintTicks(true);
jp4.add(sj1);
jp4.add(sldDiameter);
jp4.add(sj2);
c.add(jp4);
vector = new Vector();
jl = new JList(mingcheng);
jl.setVisibleRowCount(5);
jl.setFixedCellHeight(40);
jl.setFixedCellWidth(265);
jl.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
c.add(new JScrollPane(jl));
tjian = new JButton(「添加「);
shanc = new JButton(「刪除「);
qu = new JButton(「讀取「);
baocun = new JButto

摘選自網上,希望對你有幫助。

❷ 求音樂播放器java源代碼

import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;

import javax.swing.*;
import java.io.File;

class AudioPlayDemo extends JFrame implements ActionListener {
boolean looping = false;
File file1 = new File("music\\明天會更好.wav");
AudioClip sound1;
AudioClip chosenClip;

JButton playButton = new JButton("播放");
JButton loopButton = new JButton("循環播放");
JButton stopButton = new JButton("停止");
JLabel status = new JLabel("選擇播放文件");
JPanel controlPanel = new JPanel();
Container container = getContentPane();

public AudioPlayDemo() {
try {
sound1 = Applet.newAudioClip(file1.toURL());
chosenClip = sound1;
} catch(OutOfMemoryError e){
System.out.println("內存溢出");
e.printStackTrace();
} catch(Exception e){
e.printStackTrace();
}
playButton.addActionListener(this);
loopButton.addActionListener(this);
stopButton.addActionListener(this);
stopButton.setEnabled(false);

controlPanel.add(playButton);
controlPanel.add(loopButton);
controlPanel.add(stopButton);

container.add(controlPanel, BorderLayout.CENTER);
container.add(status, BorderLayout.SOUTH);

setSize(300, 130);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //關閉窗口時退出程序
}

public void actionPerformed(ActionEvent event) {
if (chosenClip == null) {
status.setText("聲音未載入");
return;
}
Object source = event.getSource(); //獲取用戶洗滌激活的按鈕

if (source == playButton) {
stopButton.setEnabled(true);
loopButton.setEnabled(true);
chosenClip.play();
status.setText("正在播放");
}

if (source == loopButton) {
looping = true;
chosenClip.loop();
loopButton.setEnabled(false);
stopButton.setEnabled(true);
status.setText("正在循環播放");
}
if (source == stopButton) {
if (looping) {
looping = false;
chosenClip.stop();
loopButton.setEnabled(true);
} else {
chosenClip.stop();
}
stopButton.setEnabled(false);
status.setText("停止播放");
}
}
public static void main(String s[]) {
new AudioPlayDemo();
}
}
這功能不齊,不能下載,也不能播放mp3格式音樂,是用來播放wav格式音樂的,(但你可以在千千靜聽里把mp3格式轉換為wav格式)

❸ 關於java MP3播放器

package ;

import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import javax.swing.*;
import javax.media.bean.playerbean.*; //這個包要用到JMF

public class MP3 extends JFrame implements Runnable {
public JLabel shijian;

private JSlider sldDiameter;

public MediaPlayer soumd1;

public JButton playSound, loopSound, stopsound;

public JButton tjian, shanc, baocun, qu;

public JPanel jp1, jp2, jp3, jp4;

public JList jl;

int zongmiao=0;

public Vector vector, mingcheng;

boolean fo = false, geshi = false;

JLabel jl1, jl2, sj1, sj2;

JTextField jt1, jt2;

JButton queding, xiugai;

int zong = 0;

int a = 0, b = 0, you = 1,mm=0;

int fenzhong, miaozhong;

public MP3() {
super("java簡單音樂播放器");
soumd1 = new MediaPlayer();
Container c = getContentPane();
c.setLayout(new FlowLayout());
mingcheng = new Vector();
jp1 = new JPanel();
shijian = new JLabel();
jp1.add(shijian);
c.add(jp1);
playSound = new JButton("開始播放");
loopSound = new JButton("循環播放");
stopsound = new JButton("停止播放");
jp2 = new JPanel();
jp2.add(playSound);
jp2.add(loopSound);
jp2.add(stopsound);
c.add(jp2);
jp4 = new JPanel();
sj1 = new JLabel();
sj2 = new JLabel();
sldDiameter = new JSlider(SwingConstants.HORIZONTAL, 0, 100, 0);
sldDiameter.setMajorTickSpacing(1);
sldDiameter.setPaintTicks(true);
jp4.add(sj1);
jp4.add(sldDiameter);
jp4.add(sj2);
c.add(jp4);
vector = new Vector();
jl = new JList(mingcheng);
jl.setVisibleRowCount(5);
jl.setFixedCellHeight(40);
jl.setFixedCellWidth(265);
jl.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
c.add(new JScrollPane(jl));
tjian = new JButton("添加");
shanc = new JButton("刪除");
qu = new JButton("讀取");
baocun = new JButton("保存");
jp3 = new JPanel();
jp3.add(tjian);
jp3.add(shanc);
jp3.add(baocun);
jp3.add(qu);
c.add(jp3);

try {
String s = "c:\\music.txt";
ObjectInputStream input = new ObjectInputStream(
new FileInputStream(s));
lujin a1 = (lujin) input.readObject();
mingcheng = a1.b;
vector = a1.a;
jl.setListData(mingcheng);
} catch (Exception e) {
System.out.println("c盤沒有保存音樂文件");
//e.printStackTrace();
}

baocun.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
JFileChooser fileChooser = new JFileChooser(); // 實例化文件選擇器
fileChooser
.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); // 設置文件選擇模式,此處為文件和目錄均可
if (fileChooser.showSaveDialog(MP3.this) == JFileChooser.APPROVE_OPTION) { // 彈出文件選擇器,並判斷是否點擊了打開按鈕
String fileName = fileChooser.getSelectedFile()
.getAbsolutePath(); // 得到選擇文件或目錄的絕對路徑
mmm(vector, mingcheng, fileName);
}
}
});
qu.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
JFileChooser fileChooser = new JFileChooser(); // 實例化文件選擇器
fileChooser
.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); // 設置文件選擇模式,此處為文件和目錄均可
if (fileChooser.showOpenDialog(MP3.this) == JFileChooser.APPROVE_OPTION) { // 彈出文件選擇器,並判斷是否點擊了打開按鈕
String fileName = fileChooser.getSelectedFile()
.getAbsolutePath(); // 得到選擇文件或目錄的絕對路徑
try {
ObjectInputStream input = new ObjectInputStream(
new FileInputStream(fileName));
lujin a1 = (lujin) input.readObject();
mingcheng = a1.b;
vector = a1.a;
jl.setListData(mingcheng);
} catch (Exception e) {
e.printStackTrace();
}
}
}
});
playSound.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (jl.getSelectedIndex() >= 0) {
String yy = (String) vector.get(jl.getSelectedIndex());
File ff = new File(yy);
if (ff.exists()) {
if (yy.matches("[\\S\\s]*.mp3")|| yy.matches("[\\S\\s]*.MP3")) {
if (soumd1 != null) {
a = 0;
b = 0;
you = 0;
soumd1.stop();
}
soumd1.setMediaLocation("file:/" + yy);
fo = true;
soumd1.start();
geshi=true;
try {
Thread.sleep(500);
} catch (InterruptedException eee) {
}
zongmiao=(int)soumd1.getDuration().getSeconds();
if(zongmiao>10000)
{
try {
Thread.sleep(500);
} catch (InterruptedException ew) {
}
zongmiao=(int)soumd1.getDuration().getSeconds();
}
zongmiao=(int)soumd1.getDuration().getSeconds();
String aa=fen(zongmiao);
sj2.setText(aa);
} else
JOptionPane.showMessageDialog(null,
"播放文件格式的有錯,無法播放 建議刪除");
} else
JOptionPane.showMessageDialog(null,
"此歌曲文件已經不存在,建議刪除");
}
else
JOptionPane.showMessageDialog(null, "請選擇音樂文件");
}
});
loopSound.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (jl.getSelectedIndex() >= 0) {
String yy = (String) vector.get(jl.getSelectedIndex());
File ff = new File(yy);
if (ff.exists()) {
if (yy.matches("[\\S\\s]*.mp3")|| yy.matches("[\\S\\s]*.MP3")) {
if (soumd1 != null) {
a = 0;
b = 0;
you = 0;
soumd1.stop();
}
soumd1.setMediaLocation("file:/" + yy);
fo = true;
soumd1.start();
geshi=true;
try {
Thread.sleep(500);
} catch (InterruptedException we) {
}
zongmiao=(int)soumd1.getDuration().getSeconds();
if(zongmiao>10000)
{
try {
Thread.sleep(500);
} catch (InterruptedException we) {
}
zongmiao=(int)soumd1.getDuration().getSeconds();
}
zongmiao=(int)soumd1.getDuration().getSeconds();
String aa=fen(zongmiao);
sj2.setText(aa);
} else
JOptionPane.showMessageDialog(null,
"播放文件格式的有錯,無法播放 建議刪除");
} else
JOptionPane.showMessageDialog(null,
"此歌曲文件已經不存在,建議刪除");

}
else
JOptionPane.showMessageDialog(null, "請選擇音樂文件");
}
});
stopsound.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
a = 0;
b = 0;
you = 0;
mm=0;
geshi=false;
fo = false;
sldDiameter.setMaximum(100);
sldDiameter.setValue(0);
sj1.setText(null);
sj2.setText(null);
if (jl.getSelectedIndex() >= 0)
soumd1.stop();

}
});
tjian.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
JFileChooser fileChooser = new JFileChooser(); // 實例化文件選擇器
fileChooser
.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); // 設置文件選擇模式,此處為文件和目錄均可
fileChooser.setCurrentDirectory(new File(".")); // 設置文件選擇器當前目錄
fileChooser
.setFileFilter(new javax.swing.filechooser.FileFilter() {
public boolean accept(File file) { // 可接受的文件類型
String name = file.getName().toLowerCase();
return name.endsWith(".mp3")
|| file.isDirectory();
}
public String getDescription() { // 文件描述
return "音樂文件(*.mp3)";
}
});
if (fileChooser.showOpenDialog(MP3.this) == JFileChooser.APPROVE_OPTION) { // 彈出文件選擇器,並判斷是否點擊了打開按鈕
String fileName = fileChooser.getSelectedFile()
.getAbsolutePath(); // 得到選擇文件或目錄的絕對路徑
vector.add(fileName);
StringBuffer buffer = xu(fileName);
mingcheng.add(buffer);
}
}
});
shanc.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (jl.getSelectedIndex() >= 0) {
mingcheng.removeElementAt(jl.getSelectedIndex());
vector.removeElementAt(jl.getSelectedIndex());
jl.setListData(mingcheng);
}
}
});
jl.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent event) {
if (event.getClickCount() == 2) {
if (jl.getSelectedIndex() >= 0) {
String yy = (String) vector.get(jl.getSelectedIndex());
File ff = new File(yy);
if (ff.exists()) {
if (yy.matches("[\\S\\s]*.mp3")|| yy.matches("[\\S\\s]*.MP3")) {
if (soumd1 != null) {
a = 0;
b = 0;
you = 0;
soumd1.stop();
}
soumd1.setMediaLocation("file:/" + yy);
fo = true;
soumd1.start();
geshi=true;
try {
Thread.sleep(500);
} catch (InterruptedException e) {
}
zongmiao=(int)soumd1.getDuration().getSeconds();
if(zongmiao>10000)
{
try {
Thread.sleep(500);
} catch (InterruptedException e) {
}
zongmiao=(int)soumd1.getDuration().getSeconds();
}
String aa=fen(zongmiao);
sj2.setText(aa);
} else
JOptionPane.showMessageDialog(null,
"播放文件格式的有錯,無法播放 建議刪除");
} else
JOptionPane.showMessageDialog(null,
"此歌曲文件已經不存在,建議刪除");

}
}
if (event.isMetaDown()) {
if (jl.getSelectedIndex() >= 0) {
int a = jl.getSelectedIndex();
xiugai x = new xiugai();
jt1.setText(mingcheng.get(jl.getSelectedIndex()) + "");
jt2.setText(vector.get(jl.getSelectedIndex()) + "");
}
}
}
});
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
String s = "c:\\music.txt";
mmm(vector, mingcheng, s);
System.exit(0);
}
});
setSize(300, 400);
setVisible(true);
}

public void run() {
while (true) {
Date now = new Date();
shijian.setText("當前時間: " + now.toString());
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
if(geshi){
you=(int)soumd1.getMediaTime().getSeconds();
mm =you%60;
if(you!=0)
if(you%60==0)
{
b++;
}
sj1.setText(b+":"+mm);
sldDiameter.setMaximum(zongmiao);
if(you!=zongmiao)
sldDiameter.setValue(you);
else {
sldDiameter.setValue(0);
mm=0;
b=0;
}
}
}
}

public StringBuffer xu(String fileName) {
String mc = "";
for (int i = fileName.length(); i >= 1; i--) {
if (fileName.charAt(i - 1) == '\\')
break;
mc += fileName.charAt(i - 1);
}
StringBuffer buffer = new StringBuffer(mc);
StringBuffer mm = buffer.reverse();
return mm;
}

public void mmm(Vector vector, Vector mingcheng, String lujin) {
lujin a = new lujin(vector, mingcheng);
try {
ObjectOutputStream output = new ObjectOutputStream(new FileOutputStream(lujin));
output.writeObject(a);
output.flush();
output.close();
} catch (Exception e) {

}
}
public String fen(int yy) {
fenzhong = (int) yy / 60;
miaozhong = (int) yy % 60;
String sss = fenzhong + ":" + miaozhong;
return sss;
}

public static void main(String agrs[]) {
MP3 s = new MP3();
Thread t1 = new Thread(s);
t1.start();
s.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

class xiugai extends JFrame {
public xiugai() {
jl1 = new JLabel("文件名");
jt1 = new JTextField(20);
jl2 = new JLabel("文件路徑");
jt2 = new JTextField(20);
xiugai = new JButton("修改");
Container c = getContentPane();
c.setLayout(new GridLayout(3, 1));
JPanel j1 = new JPanel();
JPanel j2 = new JPanel();
JPanel j3 = new JPanel();
j1.add(jl1);
j1.add(jt1);
j2.add(jl2);
j2.add(jt2);
j3.add(xiugai);
c.add(j1);
c.add(j2);
c.add(j3);
xiugai.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
mingcheng.setElementAt(jt1.getText(), jl.getSelectedIndex());
vector.setElementAt(jt2.getText(), jl.getSelectedIndex());
jl.setListData(mingcheng);
dispose();
}
});
setSize(300, 120);
setVisible(true);
}
}
}

class lujin implements Serializable {

Vector a = new Vector();

Vector b = new Vector();

public lujin(Vector vector, Vector mingcheng) {
a = vector;
b = mingcheng;
}

}

❹ JAVA做音樂播放器簡單嗎

思路很簡單,就是用第三方的java mp3解碼器完成文件播放功能,然後用swing組件包裝一下就行版。剛好業界權有一個JMF java media framework,是大名鼎鼎的sun開發的。詳看這里的官方網頁:http://java.sun.com/procts/java-media/jmf/。網上也有很多JMF教程
我曾經做過一個簡單的,支持文件列表。這是一個很好的編程訓練。

❺ java如何實現播放mp3

需要安裝windows版JMF。下載地址
http://cds.sun.com/is-bin/INTERSHOP.enfinity/WFS/CDS-CDS_Developer-Site/en_US/-/USD/VerifyItem-Start/jmf-2_1_1e-windows-i586.exe?BundledLineItemUUID=5WFIBe.pT44AAAEeUB1fac6.&OrderID=vPVIBe.p7VEAAAEeQx1fac6.&ProctID=X4zACUFBcakAAAEYzNI5AXis&FileName=/jmf-2_1_1e-windows-i586.exe

安裝後,把安裝目錄下的lib\jmf.jar引入classpath。如果不安裝,而只是把jmf.jar引用到classpath,會出現格式異常。所以,一定要安裝。

代碼如下:

import java.io.File;
import java.io.IOException;

import javax.media.CannotRealizeException;
import javax.media.Manager;
import javax.media.NoPlayerException;
import javax.media.Player;

public class MyPlayer {
private static String path = "a.mp3";

public static void main(String[] args) {
File f1 = new File(path);
try {
Player player = Manager.createRealizedPlayer(f1.toURI().toURL());
player.prefetch();
player.start();
} catch (CannotRealizeException ex) {
} catch (NoPlayerException ex) {
} catch (IOException ex) {
}
}
}

❻ 求一個最簡單的Java音樂播放器,能運行,播放的出來就行

import javax.media.*;
import java.awt.*;
import java.awt.event.*;
class MediaPlayer extends Frame implements ActionListener,
ControllerListener, ItemListener
{
Player player;
Component vc, cc;
boolean first = true, loop = false;
String currentDirectory;
MediaPlayer (String title)
{
super (title);
addWindowListener
(new WindowAdapter ()
{
public void windowClosing (WindowEvent e) {
// 用戶點擊窗口系統菜單的關閉按鈕
// 調用dispose以執行windowClosed
dispose ();
} public void windowClosed (WindowEvent e) {
if (player != null) player.close ();
System.exit (0);
}
});
Menu m = new Menu ("文件");
MenuItem mi = new MenuItem ("打開");
mi.addActionListener (this);
m.add (mi);
m.addSeparator ();
CheckboxMenuItem cbmi = new CheckboxMenuItem ("循環", false);
cbmi.addItemListener (this);
m.add (cbmi);
m.addSeparator ();
mi = new MenuItem ("退出");
mi.addActionListener (this);
m.add (mi);
MenuBar mb = new MenuBar ();
mb.add (m);
setMenuBar (mb);
setSize (200, 200);
setVisible (true);
}
public void actionPerformed (ActionEvent e)
{
if (e.getActionCommand ().equals ("退出"))
{
// 調用dispose以便執行windowClosed
dispose ();
return;
}
FileDialog fd = new FileDialog (this, "打開媒體文件",
FileDialog.LOAD);
fd.setDirectory (currentDirectory);
fd.show ();
// 如果用戶放棄選擇文件,則返回
if (fd.getFile () == null) return;
currentDirectory = fd.getDirectory ();
if (player != null)
player.close ();
try
{
player = Manager.createPlayer (new MediaLocator ("file:" + fd.getDirectory () + fd.getFile ()));
}
catch (java.io.IOException e2)
{
System.out.println (e2);
return;
}
catch (NoPlayerException e2)
{
System.out.println ("不能找到播放器.");
return;
}
if (player == null)
{
System.out.println ("無法創建播放器.");
return;
}
first = false;
setTitle (fd.getFile ());
player.addControllerListener (this);
player.prefetch ();
}
public void controllerUpdate (ControllerEvent e)
{
// 調用player.close()時ControllerClosedEvent事件出現。
// 如果存在視覺部件,則該部件應該拆除(為一致起見,
// 我們對控制面板部件也執行同樣的操作)
if (e instanceof ControllerClosedEvent)
{
if (vc != null)
{
remove (vc);
vc = null;
}
if (cc != null)
{
remove (cc);
cc = null;
}
return;
}
if (e instanceof EndOfMediaEvent)
{
if (loop)
{
player.setMediaTime (new Time (0));
player.start ();
}
return;
}
if (e instanceof PrefetchCompleteEvent)
{
player.start ();
return;
}
if (e instanceof RealizeCompleteEvent)
{
vc = player.getVisualComponent ();
if (vc != null)
add (vc);
cc = player.getControlPanelComponent ();
if (cc != null)
add (cc, BorderLayout.SOUTH);
pack ();
}
}
public void itemStateChanged (ItemEvent e)
{
loop = !loop;
}
public void paint (Graphics g)
{
if (first)
{
int w = getSize ().width;
int h = getSize ().height;
g.setColor (Color.blue);
g.fillRect (0, 0, w, h);
Font f = new Font ("DialogInput", Font.BOLD, 16);
g.setFont (f);
FontMetrics fm = g.getFontMetrics ();
int swidth = fm.stringWidth ("*** 歡迎 ***");
g.setColor (Color.white);
g.drawString ("*** 歡迎 ***",
(w - swidth) / 2,
(h + getInsets ().top) / 2);
}
// 調用超類Frame的paint()方法,該paint()方法將調用Frame包含的各個容器
// 和部件(包括控制面板部件)的paint()方法。
super.paint (g);
}
// 不執行背景清除操作,以免控制面板部件閃爍
public void update (Graphics g)
{
paint (g);
}
public static void main (String [] args) {
new MediaPlayer ("媒體播放器1.0");
} }

❼ 求用java編寫MP3播放器

這個需要jmf的相關包,去網上下載下,給你寫了個例子

public class TestPlay extends JFrame {
private Component vc, cc;
private JButton file = new JButton("file");
private Player player = null;

public TestPlay() throws HeadlessException, NoPlayerException, MalformedURLException, IOException {
this.add(file);

file.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
JFileChooser f = new JFileChooser();
if(f.showOpenDialog(null)==JFileChooser.CANCEL_OPTION)return;
try {

player = Manager.createPlayer(f.getSelectedFile().toURL());
player.addControllerListener(new ControllerListener() {
public void controllerUpdate(ControllerEvent arg0) {
controllerUpdateImp(arg0);
}
});
player.prefetch();
} catch (Exception e) {
System.out.println(e);
JOptionPane.showMessageDialog(null, e.getMessage());
}
}
});
}

public void controllerUpdateImp(ControllerEvent e) {
if (e instanceof EndOfMediaEvent) {
player.setMediaTime(new Time(0));
player.start();
} else if (e instanceof PrefetchCompleteEvent) {
player.start();
} else if (e instanceof RealizeCompleteEvent) {
vc = player.getVisualComponent();
if (vc != null) this.add(vc, BorderLayout.CENTER);
cc = player.getControlPanelComponent();
if (cc != null) this.add(cc, BorderLayout.SOUTH);
this.pack();
this.setResizable(false);
this.setVisible(true);
} else if (e instanceof ControllerClosedEvent) {
System.exit(0);
}

}

public static void main(String[] args) {
TestPlay t;
try {
t = new TestPlay();
t.setDefaultCloseOperation(t.EXIT_ON_CLOSE);
t.pack();
t.setLocationRelativeTo(null);
t.setVisible(true);
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e.getMessage());
}

}

}

閱讀全文

與java簡單的音樂播放器相關的資料

熱點內容
網路輿情應對的基本理念是什麼 瀏覽:433
word2007層次結構 瀏覽:456
去掉文件名的數字 瀏覽:713
word公司 瀏覽:710
淘寶店數據包怎麼上傳 瀏覽:341
pbt文件 瀏覽:204
HX基礎編程怎麼改變字體 瀏覽:876
怎麼開網路教學 瀏覽:915
630升級工程武器 瀏覽:936
用換機助手接收的軟體文件在哪找 瀏覽:282
閱達app一教一輔五年級有哪些 瀏覽:7
win10系統用f2調節音量 瀏覽:19
壓縮文件密碼器 瀏覽:840
線下活動數據分析有哪些 瀏覽:314
助聽器插片式編程線如何連接 瀏覽:293
怎麼刪除系統休眠文件 瀏覽:914
搜索文件內容中包含的文字並替換 瀏覽:542
微信相冊程序圖標 瀏覽:714
win8怎麼顯示文件格式 瀏覽:547
文件伺服器中毒 瀏覽:721

友情鏈接