本文整理汇总了Java中javax.sound.sampled.spi.FormatConversionProvider.getAudioInputStream方法的典型用法代码示例。如果您正苦于以下问题:Java FormatConversionProvider.getAudioInputStream方法的具体用法?Java FormatConversionProvider.getAudioInputStream怎么用?Java FormatConversionProvider.getAudioInputStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.sound.sampled.spi.FormatConversionProvider
的用法示例。
在下文中一共展示了FormatConversionProvider.getAudioInputStream方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAudioInputStream
import javax.sound.sampled.spi.FormatConversionProvider; //导入方法依赖的package包/类
/**
* Obtains an audio input stream of the indicated format, by converting the
* provided audio input stream.
* @param targetFormat the desired audio format after conversion
* @param sourceStream the stream to be converted
* @return an audio input stream of the indicated format
* @throws IllegalArgumentException if the conversion is not supported
* #see #getTargetEncodings(AudioFormat)
* @see #getTargetFormats(AudioFormat.Encoding, AudioFormat)
* @see #isConversionSupported(AudioFormat, AudioFormat)
* @see #getAudioInputStream(AudioFormat.Encoding, AudioInputStream)
*/
public static AudioInputStream getAudioInputStream(AudioFormat targetFormat,
AudioInputStream sourceStream) {
if (sourceStream.getFormat().matches(targetFormat)) {
return sourceStream;
}
List codecs = getFormatConversionProviders();
for(int i = 0; i < codecs.size(); i++) {
FormatConversionProvider codec = (FormatConversionProvider) codecs.get(i);
if(codec.isConversionSupported(targetFormat,sourceStream.getFormat()) ) {
return codec.getAudioInputStream(targetFormat,sourceStream);
}
}
// we ran out of options...
throw new IllegalArgumentException("Unsupported conversion: " + targetFormat + " from " + sourceStream.getFormat());
}
示例2: getAudioInputStream
import javax.sound.sampled.spi.FormatConversionProvider; //导入方法依赖的package包/类
/**
* Obtains an audio input stream of the indicated encoding, by converting
* the provided audio input stream.
*
* @param targetEncoding the desired encoding after conversion
* @param sourceStream the stream to be converted
* @return an audio input stream of the indicated encoding
* @throws IllegalArgumentException if the conversion is not supported
* @throws NullPointerException if {@code targetEncoding} or
* {@code sourceStream} are {@code null}
* @see #getTargetEncodings(AudioFormat.Encoding)
* @see #getTargetEncodings(AudioFormat)
* @see #isConversionSupported(AudioFormat.Encoding, AudioFormat)
* @see #getAudioInputStream(AudioFormat, AudioInputStream)
*/
public static AudioInputStream getAudioInputStream(AudioFormat.Encoding targetEncoding,
AudioInputStream sourceStream) {
Objects.requireNonNull(targetEncoding);
Objects.requireNonNull(sourceStream);
if (sourceStream.getFormat().getEncoding().equals(targetEncoding)) {
return sourceStream;
}
List<FormatConversionProvider> codecs = getFormatConversionProviders();
for(int i = 0; i < codecs.size(); i++) {
FormatConversionProvider codec = codecs.get(i);
if( codec.isConversionSupported( targetEncoding, sourceStream.getFormat() ) ) {
return codec.getAudioInputStream( targetEncoding, sourceStream );
}
}
// we ran out of options, throw an exception
throw new IllegalArgumentException("Unsupported conversion: " + targetEncoding + " from " + sourceStream.getFormat());
}
示例3: getAudioInputStream
import javax.sound.sampled.spi.FormatConversionProvider; //导入方法依赖的package包/类
/**
* Given an audio input stream, this will try to create a new audio input
* stream whose encoding matches the given target encoding. If no provider
* offers this conversion, an exception is thrown.
* @param targ the target encoding
* @param ais the original audio stream
* @return a new audio stream
* @throws IllegalArgumentException if the conversion cannot be made
*/
public static AudioInputStream getAudioInputStream(AudioFormat.Encoding targ,
AudioInputStream ais)
{
Iterator i = ServiceFactory.lookupProviders(FormatConversionProvider.class);
while (i.hasNext())
{
FormatConversionProvider prov = (FormatConversionProvider) i.next();
if (! prov.isConversionSupported(targ, ais.getFormat()))
continue;
return prov.getAudioInputStream(targ, ais);
}
throw new IllegalArgumentException("encoding not supported for stream");
}
示例4: getAudioInputStream
import javax.sound.sampled.spi.FormatConversionProvider; //导入方法依赖的package包/类
/**
* Given an audio input stream, this will try to create a new audio input
* stream whose encoding matches the given target encoding. If no provider
* offers this conversion, an exception is thrown.
* @param targ the target encoding
* @param ais the original audio stream
* @return a new audio stream
* @throws IllegalArgumentException if the conversion cannot be made
*/
public static AudioInputStream getAudioInputStream(AudioFormat.Encoding targ,
AudioInputStream ais)
{
Iterator i = ServiceFactory.lookupProviders(FormatConversionProvider.class);
while (i.hasNext())
{
FormatConversionProvider prov = (FormatConversionProvider) i.next();
if (! prov.isConversionSupported(targ, ais.getFormat()))
continue;
return prov.getAudioInputStream(targ, ais);
}
throw new IllegalArgumentException("encoding not supported for stream");
}
示例5: getAudioInputStream
import javax.sound.sampled.spi.FormatConversionProvider; //导入方法依赖的package包/类
/**
* Given an audio input stream, this will try to create a new audio input
* stream whose encoding matches the given target encoding. If no provider
* offers this conversion, an exception is thrown.
* @param targ the target encoding
* @param ais the original audio stream
* @return a new audio stream
* @throws IllegalArgumentException if the conversion cannot be made
*/
public static AudioInputStream getAudioInputStream(AudioFormat.Encoding targ,
AudioInputStream ais)
{
Iterator<FormatConversionProvider> i =
ServiceFactory.lookupProviders(FormatConversionProvider.class);
while (i.hasNext())
{
FormatConversionProvider prov = i.next();
if (! prov.isConversionSupported(targ, ais.getFormat()))
continue;
return prov.getAudioInputStream(targ, ais);
}
throw new IllegalArgumentException("encoding not supported for stream");
}