java播放器
自己建一個空的記事本 把後綴txt該成html 然後復制下面的代碼
C:\Users\Administrator\Desktop\ddd\MP3\14944729176400128.mp3 把這個路徑該成你的mp3路徑
<embed src="C:\Users\Administrator\Desktop\ddd\MP3\14944729176400128.mp3" width="480" height="100"02. loop="false" autostart="false">
</embed>
<OBJECT id=mPlayer1 classid=CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6 width=220 height=64 type='application/x-oleobject"'>
<PARAM NAME="URL" VALUE="C:\Users\Administrator\Desktop\ddd\MP3\14944729176400128.mp3">
<PARAM NAME="rate" VALUE="1">
<PARAM NAME="balance" VALUE="0">
<PARAM NAME="currentPosition" VALUE="0">
<PARAM NAME="defaultFrame" VALUE="">
<PARAM NAME="playCount" VALUE="100">
<PARAM NAME="autoStart" VALUE="-1">
<PARAM NAME="currentMarker" VALUE="0">
<PARAM NAME="invokeURLs" VALUE="-1">
<PARAM NAME="baseURL" VALUE="">
<PARAM NAME="volume" VALUE="100">
<PARAM NAME="mute" VALUE="0">
<PARAM NAME="uiMode" VALUE="full">
<PARAM NAME="stretchToFit" VALUE="0">
<PARAM NAME="windowlessVideo" VALUE="0">
<PARAM NAME="enabled" VALUE="-1">
<PARAM NAME="enableContextMenu" VALUE="0">
<PARAM NAME="fullScreen" VALUE="0">
<PARAM NAME="SAMIStyle" VALUE="">
<PARAM NAME="SAMILang" VALUE="">
<PARAM NAME="SAMIFilename" VALUE="">
<PARAM NAME="captioningID" VALUE="">
</OBJECT>
㈡ 怎麼用Java做一個Flash的播放器
:用java實現播放器 主要用到java里的媒體框架,即JMF, JMF實際上是Java的一個類包。JMF 2.1.1技術提供了先進的媒體處理能力,從而擴展了Java平台的功能。這些功能包括:媒體捕獲、壓縮、流轉、回放,以及對各種主要媒體形式和編碼的支 持,
㈢ 用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編寫多媒體播放器的代碼
這里是使用runtimegetRuntime().exec調用系統程序的代碼
Runtime.getRuntime().exec("C:/Program Files/Windows Media Player/wmplayer.exe");
Runtime.getRuntime().exec("C:/WINDOWS/system32/calc.exe");
這是調用系統播放器,嗯如果調用播放本地文件的話則用exec("","");
例如:Runtime.getRuntime().exec("D:/Program Files/TTPlayer/TTPlayer.exe E:/Kugou/祈求.mp3");
㈤ java 音樂播放器
//哈哈昨晚上剛做了一個基本功能是有美化和完善就靠你了,代碼如下:
//順便說一下你電腦里需要有javax.media包才行,沒有的話和我說。
importjava.awt.Toolkit;
importjava.awt.event.ActionEvent;
importjava.awt.event.ActionListener;
importjava.io.File;
importjavax.media.Manager;
importjavax.media.MediaLocator;
importjavax.media.Player;
importjavax.swing.AbstractAction;
importjavax.swing.JButton;
importjavax.swing.JFileChooser;
importjavax.swing.JFrame;
importjavax.swing.JLabel;
publicclassMusicDemo{
publicstaticvoidmain(Stringargs[])throwsInterruptedException{
MusicPlayermp=newMusicPlayer("音樂播放器");
}
}
{
JButtonbtnOK=newJButton("選歌");
JLabellblCaption=newJLabel("Hello!China!");
JButtonbtnCancel=newJButton("播放");
Playerplay=null;
Stringpath="";
MusicPlayer(Stringtitile){
super(titile);
doublely=Toolkit.getDefaultToolkit().getScreenSize().getHeight();
doublelx=Toolkit.getDefaultToolkit().getScreenSize().getWidth();
setLocation((int)lx/3,(int)ly/3);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(500,200);
btnOK.setBounds(0,0,80,30);
this.getContentPane().add(btnOK);
lblCaption.setBounds(5,40,120,30);
this.getContentPane().add(lblCaption);
btnCancel.setBounds(120,0,80,30);
this.getContentPane().add(btnCancel);
btnOK.addActionListener(newAbstractAction(){
publicvoidactionPerformed(ActionEvente){
lblCaption.setText("YouClickOK!");
path=open();
}
}
);
btnCancel.addActionListener(newAbstractAction(){
publicvoidactionPerformed(ActionEvente){
lblCaption.setText("YouClickCancel!");
try{
Filefile=newFile(path);
if(play==null){
if(file.exists()){
MediaLocatorlocator=newMediaLocator("file:"+file.getAbsolutePath());
play=Manager.createRealizedPlayer(locator);
play.prefetch();
add(play.getControlPanelComponent(),"South");
play.start();
}
}
}catch(Exceptione1){
e1.printStackTrace();
}
}
});
}
Stringopen(){
StringfilePath="";
JFileChooserfileChooser=newJFileChooser();
fileChooser.setDialogTitle("選擇歌...");
//fileChooser.setFileSelectionMo(JFileChooser.DIRECTORIES_ONLY);
intreturnVal=fileChooser.showOpenDialog(fileChooser);
if(returnVal==JFileChooser.APPROVE_OPTION){
filePath=fileChooser.getSelectedFile().getAbsolutePath();
}
returnfilePath;
}
@Override
publicvoidactionPerformed(ActionEvente){
//TODOAuto-generatedmethodstub
}
}
㈥ java大神求解啊,如何用java編寫一個音樂播放器,然後播放器裡面的歌可以順序播放的。
參考代碼如下
首先下載播放mp3的包,比如mp3spi1.9.4.jar。在工程中添加這個包。
播放器演示代碼如下
package com.test.audio;
import java.io.File;
import java.awt.BorderLayout;
import java.awt.FileDialog;
import java.awt.Frame;
import java.awt.GridLayout;
import java.awt.Label;
import java.awt.List;
import java.awt.Menu;
import java.awt.MenuBar;
import java.awt.MenuItem;
import java.awt.MenuShortcut;
import java.awt.Panel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.SourceDataLine;
public class MusicPlayer extends Frame {
/**
*
*/
private static final long serialVersionUID = -2605658046194599045L;
boolean isStop = true;// 控制播放線程
boolean hasStop = true;// 播放線程狀態
String filepath;// 播放文件目錄
String filename;// 播放文件名稱
AudioInputStream audioInputStream;// 文件流
AudioFormat audioFormat;// 文件格式
SourceDataLine sourceDataLine;// 輸出設備
List list;// 文件列表
Label labelfilepath;//播放目錄顯示標簽
Label labelfilename;//播放文件顯示標簽
public MusicPlayer() {
// 設置窗體屬性
setLayout(new BorderLayout());
setTitle("MP3 Music Player");
setSize(350, 370);
// 建立菜單欄
MenuBar menubar = new MenuBar();
Menu menufile = new Menu("File");
MenuItem menuopen = new MenuItem("Open", new MenuShortcut(KeyEvent.VK_O));
menufile.add(menuopen);
menufile.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
open();
}
});
menubar.add(menufile);
setMenuBar(menubar);
// 文件列表
list = new List(10);
list.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
// 雙擊時處理
if (e.getClickCount() == 2) {
// 播放選中的文件
filename = list.getSelectedItem();
play();
}
}
});
add(list, "Center");
// 信息顯示
Panel panel = new Panel(new GridLayout(2, 1));
labelfilepath = new Label("Dir:");
labelfilename = new Label("File:");
panel.add(labelfilepath);
panel.add(labelfilename);
add(panel, "North");
// 注冊窗體關閉事件
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
setVisible(true);
}
// 打開
private void open() {
FileDialog dialog = new FileDialog(this, "Open", 0);
dialog.setVisible(true);
filepath = dialog.getDirectory();
if (filepath != null) {
labelfilepath.setText("Dir:" + filepath);
// 顯示文件列表
list.removeAll();
File filedir = new File(filepath);
File[] filelist = filedir.listFiles();
for (File file : filelist) {
String filename = file.getName().toLowerCase();
if (filename.endsWith(".mp3") || filename.endsWith(".wav")) {
list.add(filename);
}
}
}
}
// 播放
private void play() {
try {
isStop = true;// 停止播放線程
// 等待播放線程停止
System.out.print("Start:" + filename);
while (!hasStop) {
System.out.print(".");
try {
Thread.sleep(10);
} catch (Exception e) {
}
}
System.out.println("");
File file = new File(filepath + filename);
labelfilename.setText("Playing:" + filename);
// 取得文件輸入流
audioInputStream = AudioSystem.getAudioInputStream(file);
audioFormat = audioInputStream.getFormat();
// 轉換mp3文件編碼
if (audioFormat.getEncoding() != AudioFormat.Encoding.PCM_SIGNED) {
audioFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED,
audioFormat.getSampleRate(), 16, audioFormat
.getChannels(), audioFormat.getChannels() * 2,
audioFormat.getSampleRate(), false);
audioInputStream = AudioSystem.getAudioInputStream(audioFormat,
audioInputStream);
}
// 打開輸出設備
DataLine.Info dataLineInfo = new DataLine.Info(
SourceDataLine.class, audioFormat,
AudioSystem.NOT_SPECIFIED);
sourceDataLine = (SourceDataLine) AudioSystem.getLine(dataLineInfo);
sourceDataLine.open(audioFormat);
sourceDataLine.start();
// 創建獨立線程進行播放
isStop = false;
Thread playThread = new Thread(new PlayThread());
playThread.start();
} catch (Exception e) {
e.printStackTrace();
}
}
class PlayThread extends Thread {
byte tempBuffer[] = new byte[320];
public void run() {
try {
int cnt;
hasStop = false;
// 讀取數據到緩存數據
while ((cnt = audioInputStream.read(tempBuffer, 0,
tempBuffer.length)) != -1) {
if (isStop)
break;
if (cnt > 0) {
// 寫入緩存數據
sourceDataLine.write(tempBuffer, 0, cnt);
}
}
// Block等待臨時數據被輸出為空
sourceDataLine.drain();
sourceDataLine.close();
hasStop = true;
} catch (Exception e) {
e.printStackTrace();
System.exit(0);
}
}
}
public static void main(String args[]) {
new MusicPlayer();
}
}
㈦ 用java 製作簡易音樂播放器
http://sourceforge.net/projects/jacomp3player/files/
java做的MP3播放器,裡面是源代碼,幾年前研究過,你看看
㈧ 如何用java做一個音樂播放器
<object id="player" height="300" width="300" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6">
<param NAME="AutoStart" VALUE="-1">
<!--是否自動播放-->
<param NAME="Balance" VALUE="0">
<!--調整左右聲道平衡,同上面舊播放器代碼-->
<param name="enabled" value="-1">
<!--播放器是否可人為控制-->
<param NAME="EnableContextMenu" VALUE="-1">
<!--是否啟用上下文菜單-->
<param NAME="url" value="song/onceLoveYou.mp3">
<!--播放的文件地址-->
<param NAME="PlayCount" VALUE="3">
<!--播放次數控制,為整數-->
<param name="rate" value="1">
<!--播放速率控制,1為正常,允許小數,1.0-2.0-->
<param name="currentPosition" value="0">
<!--控制項設置:當前位置-->
<param name="currentMarker" value="0">
<!--控制項設置:當前標記-->
<param name="defaultFrame" value="">
<!--顯示默認框架-->
<param name="invokeURLs" value="0">
<!--腳本命令設置:是否調用URL-->
<param name="baseURL" value="">
<!--腳本命令設置:被調用的URL-->
<param name="stretchToFit" value="0">
<!--是否按比例伸展-->
<param name="volume" value="50">
<!--默認聲音大小0%-100%,50則為50%-->
<param name="mute" value="0">
<!--是否靜音-->
<param name="uiMode" value="mini">
<!--播放器顯示模式:Full顯示全部;mini最簡化;None不顯示播放控制,只顯示視頻窗口;invisible全部不顯示-->
<param name="windowlessVideo" value="0">
<!--如果是0可以允許全屏,否則只能在窗口中查看-->
<param name="fullScreen" value="0">
<!--開始播放是否自動全屏-->
<param name="enableErrorDialogs" value="-1">
<!--是否啟用錯誤提示報告-->
<param name="SAMIStyle" value>
<!--SAMI樣式-->
<param name="SAMILang" value>
<!--SAMI語言-->
<param name="SAMIFilename" value>
<!--字幕ID-->
</object>
希望對你有所幫助
㈨ 怎麼用java調用vlc播放器
最簡單的方法,打開軟體中心或新立得,直接搜vlc,找到後安裝。稍微難一點的方法,打開終端,輸入命令sudo apt-get install vlc我沒有命令行安裝過vlc,不知道軟體庫里還是不是vlc,如果不是一般可以這樣解決sudo apt-get install vlc*最難的方法,下載源碼自己編譯安裝。********************************************************插件那個安裝,建議先安裝新立得(建議必裝)sudo apt-get install synaptic用sudo許可權打開後直接查找相關的插件名,然後安裝。或者用上面的方法sudo apt-get install vlc*除了vlc之外還會顯示很多可用插件,選擇你需要的,安裝即可,例如sudo apt-get install vlc vlc-dash-plugin上面命令我瞎編的不能信,具體看你終端里的反饋。
㈩ 如何用Java來編寫一個音樂播放器
首先要在環境電腦中安裝下JMF環境,才能引入javax.sound.sampled.*這個包,一下是用過的代碼
package TheMusic;
import java.io.*;
import javax.sound.sampled.*;
public class Music {
public static void main(String[] args) {
// TODO Auto-generated method stub
//修改你的音樂文件路徑就OK了
AePlayWave apw=new AePlayWave("突然好想你.wav");
apw.start();
}
}
在程序中實例化這個類,啟動線程,實例化的時候參照Test修改路徑就OK播放聲音的類
Java代碼
public class AePlayWave extends Thread {
private String filename;
public AePlayWave(String wavfile) {
filename = wavfile;
}
public void run() {
File soundFile = new File(filename);
AudioInputStream audioInputStream = null;
try {
audioInputStream = AudioSystem.getAudioInputStream(soundFile);
} catch (Exception e1) {
e1.printStackTrace();
return;
}
AudioFormat format = audioInputStream.getFormat();
SourceDataLine auline = null;
DataLine.Info info = new DataLine.Info(SourceDataLine.class, format);
try {
auline = (SourceDataLine) AudioSystem.getLine(info);
auline.open(format);
} catch (Exception e) {
e.printStackTrace();
return;
}
auline.start();
int nBytesRead = 0;
byte[] abData = new byte[512];
try {
while (nBytesRead != -1) {
nBytesRead = audioInputStream.read(abData, 0, abData.length);
if (nBytesRead >= 0)
auline.write(abData, 0, nBytesRead);
}
} catch (IOException e) {
e.printStackTrace();
return;
} finally {
auline.drain();
auline.close();
}
}
}