本文整理汇总了Java中com.jme3.audio.AudioKey.isStream方法的典型用法代码示例。如果您正苦于以下问题:Java AudioKey.isStream方法的具体用法?Java AudioKey.isStream怎么用?Java AudioKey.isStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jme3.audio.AudioKey
的用法示例。
在下文中一共展示了AudioKey.isStream方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: load
import com.jme3.audio.AudioKey; //导入方法依赖的package包/类
public Object load(AssetInfo info) throws IOException {
if (!(info.getKey() instanceof AudioKey)){
throw new IllegalArgumentException("Audio assets must be loaded using an AudioKey");
}
AudioKey key = (AudioKey) info.getKey();
boolean readStream = key.isStream();
boolean streamCache = key.useStreamCache();
InputStream in = null;
try {
in = info.openStream();
AudioData data = load(in, readStream, streamCache);
if (data instanceof AudioStream){
// audio streams must remain open
in = null;
}
return data;
} finally {
if (in != null){
in.close();
}
}
}
示例2: deleteAudioData
import com.jme3.audio.AudioKey; //导入方法依赖的package包/类
@Override
public void deleteAudioData(AudioData ad) {
if (ad instanceof AndroidAudioData) {
AndroidAudioData audioData = (AndroidAudioData) ad;
if (audioData.getAssetKey() instanceof AudioKey) {
AudioKey assetKey = (AudioKey) audioData.getAssetKey();
if (assetKey.isStream()) {
for (AudioNode src : musicPlaying.keySet()) {
if (src.getAudioData() == ad) {
MediaPlayer mp = musicPlaying.get(src);
mp.stop();
mp.release();
musicPlaying.remove(src);
src.setStatus(Status.Stopped);
src.setChannel(-1);
break;
}
}
} else {
if (audioData.getId() > 0) {
soundPool.unload(audioData.getId());
}
audioData.setId(0);
}
}
} else {
throw new IllegalArgumentException("AudioData is not of type AndroidAudioData in deleteAudioData");
}
}
示例3: load
import com.jme3.audio.AudioKey; //导入方法依赖的package包/类
public Object load(AssetInfo info) throws IOException {
if (!(info.getKey() instanceof AudioKey)){
throw new IllegalArgumentException("Audio assets must be loaded using an AudioKey");
}
AudioKey key = (AudioKey) info.getKey();
boolean readStream = key.isStream();
boolean streamCache = key.useStreamCache();
InputStream in = info.openStream();
if (readStream && streamCache){
oggStream = new CachedOggStream(in);
}else{
oggStream = new UncachedOggStream(in);
}
Collection<LogicalOggStream> streams = oggStream.getLogicalStreams();
loStream = streams.iterator().next();
// if (loStream == null){
// throw new IOException("OGG File does not contain vorbis audio stream");
// }
vorbisStream = new VorbisStream(loStream);
streamHdr = vorbisStream.getIdentificationHeader();
// commentHdr = vorbisStream.getCommentHeader();
if (!readStream){
AudioBuffer audioBuffer = new AudioBuffer();
audioBuffer.setupFormat(streamHdr.getChannels(), 16, streamHdr.getSampleRate());
audioBuffer.updateData(readToBuffer());
return audioBuffer;
}else{
AudioStream audioStream = new AudioStream();
audioStream.setupFormat(streamHdr.getChannels(), 16, streamHdr.getSampleRate());
// might return -1 if unknown
float streamDuration = computeStreamDuration();
audioStream.updateData(readToStream(), streamDuration);
return audioStream;
}
}