资源简介

需要实验报告及说明的可以去百度百科下载 https://wenku.baidu.com/view/2036c3e4294ac850ad02de80d4d8d15abf230066

资源截图

代码片段和文件信息

package Flappybirid_1;

import java.io.File;
import java.io.IOException;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.FloatControl;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.SourceDataLine;
import javax.sound.sampled.UnsupportedAudioFileException;
public class AudioPlayWave extends Thread {
    private String fileName;
    private final int EXTERNAL_BUFFER_SIZE = 524288;
    public AudioPlayWave(String wavFile) {
        this.fileName = wavFile;
    }
    public void run() {
        File soundFile = new File(fileName); // 播放音乐的文件名
        if (!soundFile.exists()) {
            System.err.println(“Wave file not found:“ + fileName);
            return;
        }
        AudioInputStream audioInputStream = null; // 创建音频输入流对象
        try {
            audioInputStream = AudioSystem.getAudioInputStream(soundFile); // 创建音频对象
        } catch (UnsupportedAudioFileException e1) {
            e1.printStackTrace();
            return;
        } catch (IOException 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 (LineUnavailableException e) {
            e.printStackTrace();
            return;
        } catch (Exception e) {
            e.printStackTrace();
            return;
        }
        if (auline.isControlSupported(FloatControl.Type.PAN)) {
            FloatControl pan = (FloatControl) auline
                    .getControl(FloatControl.Type.PAN);
        }
        auline.start();
        int nBytesRead = 0;
        byte[] abData = new byte[EXTERNAL_BUFFER_SIZE];
        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();
        }
    }
           
    
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        301  2018-05-05 09:00  FlappyBird_shh4\.classpath

     文件        391  2018-05-17 22:35  FlappyBird_shh4\.project

     文件        598  2018-05-05 09:00  FlappyBird_shh4\.settings\org.eclipse.jdt.core.prefs

     文件       3383  2018-06-08 21:50  FlappyBird_shh4\bin\Flappybirid_1\AudioPlayWave.class

     文件       4030  2018-06-08 22:14  FlappyBird_shh4\bin\Flappybirid_1\Bird.class

     文件       1803  2018-06-08 21:50  FlappyBird_shh4\bin\Flappybirid_1\Column.class

     文件       1678  2018-06-08 21:50  FlappyBird_shh4\bin\Flappybirid_1\GoldCoin.class

     文件       1076  2018-06-08 21:50  FlappyBird_shh4\bin\Flappybirid_1\Ground.class

     文件        574  2018-06-08 21:50  FlappyBird_shh4\bin\Flappybirid_1\StartGame.class

     文件       1062  2018-06-08 21:50  FlappyBird_shh4\bin\Flappybirid_1\StartPanel$1.class

     文件       1062  2018-06-08 21:50  FlappyBird_shh4\bin\Flappybirid_1\StartPanel$2.class

     文件       1814  2018-06-08 21:50  FlappyBird_shh4\bin\Flappybirid_1\StartPanel.class

     文件       2127  2018-06-08 21:50  FlappyBird_shh4\bin\Flappybirid_1\World$GamePanel$1.class

     文件       1955  2018-06-08 21:50  FlappyBird_shh4\bin\Flappybirid_1\World$GamePanel$2.class

     文件       2258  2018-06-08 21:50  FlappyBird_shh4\bin\Flappybirid_1\World$GamePanel$3.class

     文件       3683  2018-06-08 21:50  FlappyBird_shh4\bin\Flappybirid_1\World$GamePanel.class

     文件        840  2018-06-08 21:50  FlappyBird_shh4\bin\Flappybirid_1\World.class

     文件       3567  2018-05-06 12:00  FlappyBird_shh4\bin\images\ground.png

     文件       7399  2016-08-06 13:31  FlappyBird_shh4\bin\images\Over.png

     文件       5238  2016-08-06 13:31  FlappyBird_shh4\bin\images\Pipe_Down.png

     文件       5461  2016-08-06 13:31  FlappyBird_shh4\bin\images\Pipe_Up.png

     文件       3165  2018-05-08 12:04  FlappyBird_shh4\bin\images\player0_0.png

     文件       3173  2018-05-08 12:04  FlappyBird_shh4\bin\images\player0_1.png

     文件       3160  2018-05-08 12:04  FlappyBird_shh4\bin\images\player0_2.png

     文件       3173  2018-05-08 12:04  FlappyBird_shh4\bin\images\player0_3.png

     文件       3185  2018-05-08 12:04  FlappyBird_shh4\bin\images\player0_4.png

     文件       3173  2018-05-08 12:04  FlappyBird_shh4\bin\images\player0_5.png

     文件       3160  2018-05-08 12:04  FlappyBird_shh4\bin\images\player0_6.png

     文件       3173  2018-05-08 12:04  FlappyBird_shh4\bin\images\player0_7.png

     文件       3182  2018-05-08 12:04  FlappyBird_shh4\bin\images\player1_0.png

............此处省略81个文件信息

评论

共有 条评论