package com.rjxy.Music1_1;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import javazoom.jl.decoder.JavaLayerException;
import javazoom.jl.player.Player;
public class Music1 implements Runnable{
String path = "D:/java/青柠.wav";
File file = null;
BufferedInputStream is = null;
//mian()方法
public static void main(String args[]) {
Music1 music = new Music1();
Thread thread = new Thread(music);
thread.start();
}
//重写run()
public void run() {
try {
file = new File(path);
is = new BufferedInputStream(new FileInputStream(file));
System.out.println(file.getName()+" 加载成功!");
} catch (FileNotFoundException e) {
System.out.println(file.getName()+" 加载失败!");
e.printStackTrace();
}
try {
new Player(is);
System.out.println("palyer创建成功!");
} catch (JavaLayerException e) {
System.out.println("player创建失败!");
e.printStackTrace();
}
try {
Thread.sleep(64000);
System.out.println("Thread休眠!");
} catch (InterruptedException e) {
System.out.println("Thread休眠失败!");
e.printStackTrace();
}
}
}
为什么编译运行都不报错,但是为什么没有声音?
求大佬帮忙