About a year ago, I started creating an Android app. Now, when I try to run it, I get an exception from the AudioInputStream class. After a short research that I did with GOOGLE, I found out that android no longer supports this class ... Is this their alternative?
This is the code I wrote:
private void merge2WavFiles(String wavFile1, String wavFile2, String newWavFilePath) { try { File wave1 = new File(wavFile1); if(!wave1.exists()) throw new Exception(wave1.getPath() + " - File Not Found"); AudioInputStream clip1 = AudioSystem.getAudioInputStream(wave1); AudioInputStream clip2 = AudioSystem.getAudioInputStream(new File(wavFile2)); AudioInputStream emptyClip = AudioSystem.getAudioInputStream(new File(emptyWavPath)); AudioInputStream appendedFiles = new AudioInputStream( new SequenceInputStream(clip1, emptyClip), clip1.getFormat(), clip1.getFrameLength() + 100 ); clip1 = appendedFiles; appendedFiles = new AudioInputStream( new SequenceInputStream(clip1, clip2), clip1.getFormat(), clip1.getFrameLength() + clip2.getFrameLength() ); AudioSystem.write(appendedFiles, AudioFileFormat.Type.WAVE, new File(newWavFilePath)); } catch (Exception e) { e.printStackTrace(); } }
source share