Search in sources :

Example 31 with AudioFileFormat

use of javax.sound.sampled.AudioFileFormat in project jdk8u_jdk by JetBrains.

the class WaveFloatFileReader method getAudioFileFormat.

public AudioFileFormat getAudioFileFormat(File file) throws UnsupportedAudioFileException, IOException {
    InputStream stream = new FileInputStream(file);
    AudioFileFormat format;
    try {
        format = getAudioFileFormat(new BufferedInputStream(stream));
    } finally {
        stream.close();
    }
    return format;
}
Also used : BufferedInputStream(java.io.BufferedInputStream) BufferedInputStream(java.io.BufferedInputStream) FileInputStream(java.io.FileInputStream) AudioInputStream(javax.sound.sampled.AudioInputStream) InputStream(java.io.InputStream) FileInputStream(java.io.FileInputStream) AudioFileFormat(javax.sound.sampled.AudioFileFormat)

Example 32 with AudioFileFormat

use of javax.sound.sampled.AudioFileFormat in project Minim by ddf.

the class MpegAudioFileReader method getAudioFileFormat.

/**
	 * Returns AudioFileFormat from URL.
	 */
public AudioFileFormat getAudioFileFormat(URL url) throws UnsupportedAudioFileException, IOException {
    if (TDebug.TraceAudioFileReader) {
        TDebug.out("MpegAudioFileReader.getAudioFileFormat(URL): begin");
    }
    long lFileLengthInBytes = AudioSystem.NOT_SPECIFIED;
    URLConnection conn = url.openConnection();
    // Tell shoucast server (if any) that SPI support shoutcast stream.
    conn.setRequestProperty("Icy-Metadata", "1");
    InputStream inputStream = conn.getInputStream();
    AudioFileFormat audioFileFormat = null;
    try {
        audioFileFormat = getAudioFileFormat(inputStream, lFileLengthInBytes);
    } finally {
        inputStream.close();
    }
    if (TDebug.TraceAudioFileReader) {
        TDebug.out("MpegAudioFileReader.getAudioFileFormat(URL): end");
    }
    return audioFileFormat;
}
Also used : BufferedInputStream(java.io.BufferedInputStream) IcyInputStream(javazoom.spi.mpeg.sampled.file.tag.IcyInputStream) PushbackInputStream(java.io.PushbackInputStream) AudioInputStream(javax.sound.sampled.AudioInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) URLConnection(java.net.URLConnection) MpegAudioFileFormat(javazoom.spi.mpeg.sampled.file.MpegAudioFileFormat) AudioFileFormat(javax.sound.sampled.AudioFileFormat)

Aggregations

AudioFileFormat (javax.sound.sampled.AudioFileFormat)32 AudioInputStream (javax.sound.sampled.AudioInputStream)20 FileInputStream (java.io.FileInputStream)18 InputStream (java.io.InputStream)13 BufferedInputStream (java.io.BufferedInputStream)11 AudioFormat (javax.sound.sampled.AudioFormat)10 DataInputStream (java.io.DataInputStream)9 UnsupportedAudioFileException (javax.sound.sampled.UnsupportedAudioFileException)8 File (java.io.File)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 PushbackInputStream (java.io.PushbackInputStream)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 URLConnection (java.net.URLConnection)1 Type (javax.sound.sampled.AudioFileFormat.Type)1 LineUnavailableException (javax.sound.sampled.LineUnavailableException)1 Mixer (javax.sound.sampled.Mixer)1