JAVA class to play sounds using the Clip

	String FilePath="C:\\Users\\sunling\\Documents\\Killercars's Files\\JavaWorkspace\\ChordRepeat";
	try{
		File file = new File(FilePath+"\\4250.wav");
		AudioInputStream audioIn = AudioSystem.getAudioInputStream(file);  
		Clip clip = AudioSystem.getClip();
		clip.open(audioIn);
		clip.loop(Clip.LOOP_CONTINUOUSLY);//循环播放 其他 可用方法有start()和stop()
	} catch (UnsupportedAudioFileException e) {  
            e.printStackTrace();  
        } catch (IOException e) {  
            e.printStackTrace();  
        } catch (LineUnavailableException e) {  
            e.printStackTrace();  
        } 

Code is very short, debugging and found no exception is thrown but is no sound (.....

Solutions to end plus Thread.sleep (10000);

The actual use does not have this problem

Also with the start () is not a single player play () ....... did not notice a lot of introduction written play () This method did not

Guess you like

Origin blog.csdn.net/Excaliburrr/article/details/54576468