Info inf[]=AudioSystem.getMixerInfo(); Mixer myOutputMixer=null; // find sound device with fancy name for(int i=0;i<inf.length;i++){> String a=inf[i].getDescription(); String name=inf[i].getName(); if(name.startsWith("USB HAMA (USB Sound Device) ")){ myOutputMixer=AudioSystem.getMixer(inf[i]); } } // play sound File soundFile = new File("Sounds/chord.wav"); AudioInputStream sound = AudioSystem.getAudioInputStream(soundFile); try { Clip sline = (Clip)myOutputMixer.getLine( new DataLine.Info(Clip.class,sound.getFormat()) ); sline.open(sound); sline.start(); } catch (LineUnavailableException ex) { }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)