当前位置: 首页>>代码示例>>Java>>正文


Java FormatConversionProvider.getAudioInputStream方法代码示例

本文整理汇总了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());
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:32,代码来源:AudioSystem.java

示例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());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:35,代码来源:AudioSystem.java

示例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");
}
 
开发者ID:vilie,项目名称:javify,代码行数:23,代码来源:AudioSystem.java

示例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");
}
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:23,代码来源:AudioSystem.java

示例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");
}
 
开发者ID:cfriedt,项目名称:classpath,代码行数:24,代码来源:AudioSystem.java


注:本文中的javax.sound.sampled.spi.FormatConversionProvider.getAudioInputStream方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。