当前位置:首页 » 编程语言 » java播放器

java播放器

发布时间: 2022-04-17 01:11:55

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();

}

}

}

热点内容
内置存储卡可以拆吗 发布:2025-05-18 04:16:35 浏览:336
编译原理课时设置 发布:2025-05-18 04:13:28 浏览:378
linux中进入ip地址服务器 发布:2025-05-18 04:11:21 浏览:612
java用什么软件写 发布:2025-05-18 03:56:19 浏览:32
linux配置vim编译c 发布:2025-05-18 03:55:07 浏览:107
砸百鬼脚本 发布:2025-05-18 03:53:34 浏览:945
安卓手机如何拍视频和苹果一样 发布:2025-05-18 03:40:47 浏览:742
为什么安卓手机连不上苹果7热点 发布:2025-05-18 03:40:13 浏览:803
网卡访问 发布:2025-05-18 03:35:04 浏览:511
接收和发送服务器地址 发布:2025-05-18 03:33:48 浏览:372