/** * Obtains a List containing installed instances of the providers for the * requested service. The returned List is immutable. * * @param serviceClass The type of providers requested. This should be one * of AudioFileReader.class, AudioFileWriter.class, * FormatConversionProvider.class, MixerProvider.class, * MidiDeviceProvider.class, MidiFileReader.class, * MidiFileWriter.class or SoundbankReader.class. * * @return A List of providers of the requested type. This List is * immutable. */ public static List<?> getProviders(final Class<?> serviceClass) { final List<?> providers; if (!MixerProvider.class.equals(serviceClass) && !FormatConversionProvider.class.equals(serviceClass) && !AudioFileReader.class.equals(serviceClass) && !AudioFileWriter.class.equals(serviceClass) && !MidiDeviceProvider.class.equals(serviceClass) && !SoundbankReader.class.equals(serviceClass) && !MidiFileWriter.class.equals(serviceClass) && !MidiFileReader.class.equals(serviceClass)) { providers = new ArrayList<>(0); } else { providers = JSSecurityManager.getProviders(serviceClass); } return Collections.unmodifiableList(providers); }
/** * Obtains the audio file format of the provided input stream. The stream must * point to valid audio file data. The implementation of this method may require * multiple parsers to examine the stream to determine whether they support it. * These parsers must be able to mark the stream, read enough data to determine whether they * support the stream, and, if not, reset the stream's read pointer to its original * position. If the input stream does not support these operations, this method may fail * with an <code>IOException</code>. * @param stream the input stream from which file format information should be * extracted * @return an <code>AudioFileFormat</code> object describing the stream's audio file format * @throws UnsupportedAudioFileException if the stream does not point to valid audio * file data recognized by the system * @throws IOException if an input/output exception occurs * @see InputStream#markSupported * @see InputStream#mark */ public static AudioFileFormat getAudioFileFormat(InputStream stream) throws UnsupportedAudioFileException, IOException { List providers = getAudioFileReaders(); AudioFileFormat format = null; for(int i = 0; i < providers.size(); i++ ) { AudioFileReader reader = (AudioFileReader) providers.get(i); try { format = reader.getAudioFileFormat( stream ); // throws IOException break; } catch (UnsupportedAudioFileException e) { continue; } } if( format==null ) { throw new UnsupportedAudioFileException("file is not a supported file type"); } else { return format; } }
/** * Obtains the audio file format of the specified URL. The URL must * point to valid audio file data. * @param url the URL from which file format information should be * extracted * @return an <code>AudioFileFormat</code> object describing the audio file format * @throws UnsupportedAudioFileException if the URL does not point to valid audio * file data recognized by the system * @throws IOException if an input/output exception occurs */ public static AudioFileFormat getAudioFileFormat(URL url) throws UnsupportedAudioFileException, IOException { List providers = getAudioFileReaders(); AudioFileFormat format = null; for(int i = 0; i < providers.size(); i++ ) { AudioFileReader reader = (AudioFileReader) providers.get(i); try { format = reader.getAudioFileFormat( url ); // throws IOException break; } catch (UnsupportedAudioFileException e) { continue; } } if( format==null ) { throw new UnsupportedAudioFileException("file is not a supported file type"); } else { return format; } }
/** * Obtains the audio file format of the specified <code>File</code>. The <code>File</code> must * point to valid audio file data. * @param file the <code>File</code> from which file format information should be * extracted * @return an <code>AudioFileFormat</code> object describing the audio file format * @throws UnsupportedAudioFileException if the <code>File</code> does not point to valid audio * file data recognized by the system * @throws IOException if an I/O exception occurs */ public static AudioFileFormat getAudioFileFormat(File file) throws UnsupportedAudioFileException, IOException { List providers = getAudioFileReaders(); AudioFileFormat format = null; for(int i = 0; i < providers.size(); i++ ) { AudioFileReader reader = (AudioFileReader) providers.get(i); try { format = reader.getAudioFileFormat( file ); // throws IOException break; } catch (UnsupportedAudioFileException e) { continue; } } if( format==null ) { throw new UnsupportedAudioFileException("file is not a supported file type"); } else { return format; } }
/** * Obtains an audio input stream from the provided input stream. The stream must * point to valid audio file data. The implementation of this method may * require multiple parsers to * examine the stream to determine whether they support it. These parsers must * be able to mark the stream, read enough data to determine whether they * support the stream, and, if not, reset the stream's read pointer to its original * position. If the input stream does not support these operation, this method may fail * with an <code>IOException</code>. * @param stream the input stream from which the <code>AudioInputStream</code> should be * constructed * @return an <code>AudioInputStream</code> object based on the audio file data contained * in the input stream. * @throws UnsupportedAudioFileException if the stream does not point to valid audio * file data recognized by the system * @throws IOException if an I/O exception occurs * @see InputStream#markSupported * @see InputStream#mark */ public static AudioInputStream getAudioInputStream(InputStream stream) throws UnsupportedAudioFileException, IOException { List providers = getAudioFileReaders(); AudioInputStream audioStream = null; for(int i = 0; i < providers.size(); i++ ) { AudioFileReader reader = (AudioFileReader) providers.get(i); try { audioStream = reader.getAudioInputStream( stream ); // throws IOException break; } catch (UnsupportedAudioFileException e) { continue; } } if( audioStream==null ) { throw new UnsupportedAudioFileException("could not get audio input stream from input stream"); } else { return audioStream; } }
/** * Obtains an audio input stream from the URL provided. The URL must * point to valid audio file data. * @param url the URL for which the <code>AudioInputStream</code> should be * constructed * @return an <code>AudioInputStream</code> object based on the audio file data pointed * to by the URL * @throws UnsupportedAudioFileException if the URL does not point to valid audio * file data recognized by the system * @throws IOException if an I/O exception occurs */ public static AudioInputStream getAudioInputStream(URL url) throws UnsupportedAudioFileException, IOException { List providers = getAudioFileReaders(); AudioInputStream audioStream = null; for(int i = 0; i < providers.size(); i++ ) { AudioFileReader reader = (AudioFileReader) providers.get(i); try { audioStream = reader.getAudioInputStream( url ); // throws IOException break; } catch (UnsupportedAudioFileException e) { continue; } } if( audioStream==null ) { throw new UnsupportedAudioFileException("could not get audio input stream from input URL"); } else { return audioStream; } }
/** * Obtains an audio input stream from the provided <code>File</code>. The <code>File</code> must * point to valid audio file data. * @param file the <code>File</code> for which the <code>AudioInputStream</code> should be * constructed * @return an <code>AudioInputStream</code> object based on the audio file data pointed * to by the <code>File</code> * @throws UnsupportedAudioFileException if the <code>File</code> does not point to valid audio * file data recognized by the system * @throws IOException if an I/O exception occurs */ public static AudioInputStream getAudioInputStream(File file) throws UnsupportedAudioFileException, IOException { List providers = getAudioFileReaders(); AudioInputStream audioStream = null; for(int i = 0; i < providers.size(); i++ ) { AudioFileReader reader = (AudioFileReader) providers.get(i); try { audioStream = reader.getAudioInputStream( file ); // throws IOException break; } catch (UnsupportedAudioFileException e) { continue; } } if( audioStream==null ) { throw new UnsupportedAudioFileException("could not get audio input stream from input file"); } else { return audioStream; } }