资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

java代码怎么插入音乐 java实现音乐播放

java如何加入音乐

public class Sound {

创新互联网站建设公司,提供成都做网站、成都网站制作、成都外贸网站建设,网页设计,建网站,PHP网站建设等专业做网站服务;可快速的进行网站开发网页制作和功能扩展;专业做搜索引擎喜爱的网站,是专业的做网站团队,希望更多企业前来合作!

public static void main(String args[]) {

try {

FileInputStream fileau = new FileInputStream(new File("c:/a.wav"));

AudioStream as = new AudioStream(fileau);

AudioPlayer.player.start(as);

} catch (Exception e) {

}

}

}

java jsp中怎么插入背景音乐(要直接打开就放的那种)

只要在HTML上添加以上代码就OK了,前提是电脑上已经安装了播放器,如RealPlay。

embed

src="C:/mp3/10.19/画心.mp3"

width="480"

height="100"

loop="false"

autostart="false"

/embed

更多设置如下:

1、如果要播放rm,ra,ram类型的音乐,代码如下:

embed

width="0"

height="0"

type="audio/x-pn-realaudio-plugin"

autostart="true"

controls="ControlPanel"

src="";

2、

如果要播放midi,asf,wma,asx类型的音乐,代码如下:

embed

autostart="true"

loop="-1"

controls="ControlPanel"

width="0"

height="0"

src="";

只需要把整段代码copy复制到文章中(编辑文章的时请先点击HTML代码模式再粘贴代码,否则这段代码会以文本形式显示出来,不能被执行),用你喜欢及可用的音乐文件的URL(网址)代替上面白色显示的音乐地址代码就可以了。

用java 如何在游戏中插入音乐

java好像只支持wav格式的音乐文件,你可以用 格式化工厂 转换一下。。再用下面代码:

import java.applet.Applet;

import java.applet.AudioClip;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.io.File;

import java.net.URI;

import java.net.URL;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JPanel;

public class f extends JFrame implements ActionListener {

private static final String AudioClip = null;

private JButton Oj;

private JButton Oj1;

AudioClip clip =null;

File musicFile;

URI uri;

URL url;

private void f() throws InterruptedException{

musicFile = new File("/zxc.wav");

uri = musicFile.toURI();

try {

url = uri.toURL();

} catch (Exception e) {

}

clip=Applet.newAudioClip(url);

//clip.play();

}

f() {

this.setSize(800, 600);

this.setResizable(false);

JPanel p = new JPanel();

this.setContentPane(p);

this.setVisible(true);

Oj = new JButton("开始");

Oj1 = new JButton("结束");

this.setVisible(true);

Oj.addActionListener(this);

Oj1.addActionListener(this);

this.add(Oj);

this.add(Oj1);

}

public static void main(String[] args) throws InterruptedException {

f ff=new f();

ff.f();

}

public void actionPerformed(ActionEvent e) {

// TODO Auto-generated method stub

if (e.getSource() == Oj) {

play();

} else if (e.getSource() == Oj1) {

stop();

//System.exit(0);

}

}

public void play() {

if (clip != null)

( (java.applet.AudioClip) clip).play();

}

public void stop() {

if (clip != null)

( (java.applet.AudioClip) clip).stop();

}

}


分享题目:java代码怎么插入音乐 java实现音乐播放
网页地址:http://cdkjz.cn/article/dopdocc.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220