符合中小企业对网站设计、功能常规化式的企业展示型网站建设
本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...
商城网站建设因基本功能的需求不同费用上面也有很大的差别...
手机微信网站开发、微信官网、微信商城网站...
播放音乐的代码 了解一下 可以直接加到小游戏里
公司主营业务:成都网站设计、网站建设、移动网站开发等业务。帮助企业客户真正实现互联网宣传,提高企业的竞争能力。创新互联公司是一支青春激扬、勤奋敬业、活力青春激扬、勤奋敬业、活力澎湃、和谐高效的团队。公司秉承以“开放、自由、严谨、自律”为核心的企业文化,感谢他们对我们的高要求,感谢他们从不同领域给我们带来的挑战,让我们激情的团队有机会用头脑与智慧不断的给客户带来惊喜。创新互联公司推出大埔免费做网站回馈大家。
package com.music.test;
import javazoom.jl.decoder.JavaLayerException;
import javazoom.jl.player.Player;
import 陪配java.io.*;
public class Music {
private String music;
private Player player;
public 扮伍 Music() throws FileNotFoundException, JavaLayerException {
FileInputStream 厅乱或file = new FileInputStream("e:/闹钟.mp3");
BufferedInputStream name = new BufferedInputStream(file);
player = new Player(name);
player.play();
}
public static void main(String[] args) throws FileNotFoundException, JavaLayerException{
new Music();
}
}
复制粘贴,采纳即可。
import java.applet.AudioClip;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.io.File;
import java.io.IOException;
import java点虐 .MalformedURLException;
import java点虐 .URL;
import javax.imageio.ImageIO;
import javax.swing.JApplet;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class Keygame
{
private final static int WIDTH = 800;
private final static int HEIGHT = 600;
public static void main ( String[] args )
{
JFrame jFrame = new JFrame ();
jFrame.setTitle ("指法练习");
jFrame.setBounds (300, 50, WIDTH, HEIGHT);
jFrame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
Mypanel mp = new Mypanel (WIDTH, HEIGHT);
jFrame.add (mp);
Thread thread = new Thread (mp);
thread.start ();
jFrame.addKeyListener (mp);
jFrame.setVisible (true);
}
}
class Mypanel extends JPanel implements Runnable, KeyListener
{
private static final 扮清long serialVersionUID = 1L;
int width, height;
int x[] = new int[10];
int y[] = new int[10];
char 简空c[] = new char[10];
int score = 1000;
Image bgImage;
AudioClip christmas = loadSound ("christmas.wav");
public Mypanel ( int width, int height )
{
this.width = width;
this.height = height;
try
{
bgImage = ImageIO.read (new File ("christmas.jpg"));
}
catch (IOException e)
{
e.printStackTrace ();
}
for ( int i = 0; i 10; i++ )
{
x[i] = (int) ( Math.random () * 800 );
y[i] = (int) ( Math.random () * 600 );
c[i] = (char) ( Math.random () * 26 + 97 );
}
christmas.loop ();
}
public void paint ( Graphics g )
{
super.paint (g);
g.drawImage (bgImage, 0, 0, width, height, 拦缺瞎this);
g.setFont (new Font (Font.DIALOG, Font.BOLD, 17));
for ( int i = 0; i 10; i++ )
{
g.setColor (Color.WHITE);
g.drawString (new Character (c[i]).toString (), x[i], y[i]);
g.setColor (Color.green);
g.drawString ("score: " + score, 5, 15);
}
g.dispose ();
}
public void run ()
{
while (true)
{
for ( int i = 0; i 10; i++ )
{
y[i]++;
if (y[i] 800)
{
y[i] = 0;
x[i] = (int) ( Math.random () * 600 );
c[i] = (char) ( Math.random () * 26 + 97 );
score -= 10;
}
}
try
{
Thread.sleep (10);
}
catch (Exception e0000)
{
e0000.printStackTrace ();
}
repaint ();
}
}
public AudioClip loadSound ( String filename )
{
URL url = null;
try
{
url = new URL ("file:" + filename);
}
catch (MalformedURLException e)
{}
return JApplet.newAudioClip (url);
}
@Override
public void keyPressed ( KeyEvent e )
{
char keyChar = e.getKeyChar ();
int nowY = -1;
int index = -1;
for ( int i = 0; i 10; i++ )
{
if (keyChar == c[i])
{
if (y[i] nowY)
{
nowY = y[i];
index = i;
}
score += 10;
}
}
if (index != -1)
{
y[index] = 0;
x[index] = (int) ( Math.random () * 800 );
c[index] = (char) ( Math.random () * 26 + 97 );
}
}
@Override
public void keyReleased ( KeyEvent e )
{}
@Override
public void keyTyped ( KeyEvent e )
{}
}
我给你一段代码吧,你可以试着修改着用bgsound
src="music/shouye.mp3"
loop="-1"
/你可以把代码复制到/head后面,盯仔“music/shouye.mp3”部分注意换成你自己音乐文件的位置(地址可以不用手动输入,直接打空格scr=后凯陆汪可以选择)。其中
loop代表悉扒循环="-1"代表循环无穷次。