本文整理汇总了Java中paulscode.sound.ICodec类的典型用法代码示例。如果您正苦于以下问题:Java ICodec类的具体用法?Java ICodec怎么用?Java ICodec使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ICodec类属于paulscode.sound包,在下文中一共展示了ICodec类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerCodec
import paulscode.sound.ICodec; //导入依赖的package包/类
private static void registerCodec(Class<? extends ICodec> cls, String ext, String... mimeTypes) {
try {
SoundSystemConfig.setCodec(ext, cls);
for (String type : mimeTypes)
NotEnoughCodecs.KNOWN_MIME_TYPES.put(type, ext);
} catch (Throwable t) {
Log.warn(t, "Can't register codec %s for extension %s", cls.getName(), ext);
}
}
示例2: loadSound
import paulscode.sound.ICodec; //导入依赖的package包/类
/**
* Pre-loads a sound into memory.
* @param filenameURL Filename/URL of a sound file to load.
* @return True if the sound loaded properly.
*/
@Override
public boolean loadSound( FilenameURL filenameURL )
{
// Make sure the buffer map exists:
if( bufferMap == null )
{
bufferMap = new HashMap<String, SoundBuffer>();
importantMessage( "Buffer Map was null in method 'loadSound'" );
}
// make sure they gave us a filename:
if( errorCheck( filenameURL == null,
"Filename/URL not specified in method 'loadSound'" ) )
return false;
// check if it is already loaded:
if( bufferMap.get( filenameURL.getFilename() ) != null )
return true;
ICodec codec = SoundSystemConfig.getCodec( filenameURL.getFilename() );
if( errorCheck( codec == null, "No codec found for file '" +
filenameURL.getFilename() +
"' in method 'loadSound'" ) )
return false;
URL url = filenameURL.getURL();
if( errorCheck( url == null, "Unable to open file '" +
filenameURL.getFilename() +
"' in method 'loadSound'" ) )
return false;
codec.initialize( url );
SoundBuffer buffer = codec.readAll();
codec.cleanup();
codec = null;
if( buffer != null )
bufferMap.put( filenameURL.getFilename(), buffer );
else
errorMessage( "Sound buffer null in method 'loadSound'" );
return true;
}