Java Code Examples for com.jme3.audio.AudioKey#isStream()
The following examples show how to use
com.jme3.audio.AudioKey#isStream() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OGGLoader.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override 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 (readStream && !streamCache) { // we still need the stream in this case .. in = null; } return data; } finally { if (in != null){ in.close(); } } }
Example 2
Source File: OGGLoader.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
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(); } } }
Example 3
Source File: NativeVorbisLoader.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public Object load(AssetInfo assetInfo) throws IOException { AudioKey key = (AudioKey) assetInfo.getKey(); if (!(assetInfo instanceof AndroidLocator.AndroidAssetInfo)) { throw new UnsupportedOperationException("Cannot load audio files from classpath." + "Place your audio files in " + "Android's assets directory"); } if (key.isStream()) { return loadStream(assetInfo); } else { return loadBuffer(assetInfo); } }
Example 4
Source File: AndroidAudioRenderer.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
@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"); } }