List of usage examples for javax.sound.sampled AudioSystem isConversionSupported
public static boolean isConversionSupported(AudioFormat targetFormat, AudioFormat sourceFormat)
From source file:marytts.tests.junit4.EnvironmentTest.java
@Test public void testMP3Available() throws Exception { AudioFormat mp3af = new AudioFormat(new AudioFormat.Encoding("MPEG1L3"), AudioSystem.NOT_SPECIFIED, AudioSystem.NOT_SPECIFIED, 1, AudioSystem.NOT_SPECIFIED, AudioSystem.NOT_SPECIFIED, false); AudioInputStream waveStream = AudioSystem .getAudioInputStream(this.getClass().getResourceAsStream("test.wav")); // Now attempt conversion: if (MaryRuntimeUtils.canCreateMP3()) { assertTrue(AudioSystem.isConversionSupported(mp3af, waveStream.getFormat())); AudioInputStream mp3Stream = AudioSystem.getAudioInputStream(mp3af, waveStream); } else {/*from ww w . j av a2s. c o m*/ assertFalse(AudioSystem.isConversionSupported(mp3af, waveStream.getFormat())); } }