本文整理匯總了Java中com.jme3.audio.AudioContext類的典型用法代碼示例。如果您正苦於以下問題:Java AudioContext類的具體用法?Java AudioContext怎麽用?Java AudioContext使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
AudioContext類屬於com.jme3.audio包,在下文中一共展示了AudioContext類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: play
import com.jme3.audio.AudioContext; //導入依賴的package包/類
/**
* 播放聲音文件
*/
public void play() {
if (audio == null) {
return;
}
// 聲音文件在播放的時候需要在渲染線程,不然會報錯。
// Caused by: java.lang.IllegalStateException: No audio renderer available, make sure call is being performed on render thread.
// at com.jme3.audio.AudioNode.getRenderer(AudioNode.java:207)
// at com.jme3.audio.AudioNode.play(AudioNode.java:218)
// at name.huliqing.core.object.sound.Sound.play(Sound.java:43)
if (AudioContext.getAudioRenderer() == null) {
return;
}
if (data.isInstance()) {
audio.playInstance();
} else {
audio.play();
}
}
示例2: stop
import com.jme3.audio.AudioContext; //導入依賴的package包/類
/**
* 停止聲音
*/
public void stop() {
if (audio == null || AudioContext.getAudioRenderer() == null) {
return;
}
audio.stop();
}
示例3: setLoop
import com.jme3.audio.AudioContext; //導入依賴的package包/類
/**
* 設置聲音循環
* @param loop
*/
public void setLoop(boolean loop) {
if (audio == null || AudioContext.getAudioRenderer() == null) {
return;
}
audio.setLooping(loop);
}
示例4: initAudio
import com.jme3.audio.AudioContext; //導入依賴的package包/類
private void initAudio(){
if (settings.getAudioRenderer() != null && context.getType() != Type.Headless){
audioRenderer = JmeSystem.newAudioRenderer(settings);
audioRenderer.initialize();
AudioContext.setAudioRenderer(audioRenderer);
listener = new Listener();
audioRenderer.setListener(listener);
}
}
示例5: update
import com.jme3.audio.AudioContext; //導入依賴的package包/類
/**
* Do not call manually.
* Callback from ContextListener.
*/
public void update(){
// Make sure the audio renderer is available to callables
AudioContext.setAudioRenderer(audioRenderer);
AppTask<?> task = taskQueue.poll();
toploop: do {
if (task == null) break;
while (task.isCancelled()) {
task = taskQueue.poll();
if (task == null) break toploop;
}
task.invoke();
} while (((task = taskQueue.poll()) != null));
if (speed == 0 || paused)
return;
timer.update();
if (inputEnabled){
inputManager.update(timer.getTimePerFrame());
}
if (audioRenderer != null){
audioRenderer.update(timer.getTimePerFrame());
}
// user code here..
}
示例6: pause
import com.jme3.audio.AudioContext; //導入依賴的package包/類
public void pause() {
if (audio == null || AudioContext.getAudioRenderer() == null) {
return;
}
audio.pause();
}
示例7: setVolume
import com.jme3.audio.AudioContext; //導入依賴的package包/類
public void setVolume(float volume) {
if (audio == null || AudioContext.getAudioRenderer() == null) {
return;
}
audio.setVolume(MathUtils.clamp(volume, 0f, 1.0f));
}