Hi,
I wanted to play a recorded conversation during my animation. I used following code for that.
[java]
private void playDialogs(AudioRenderer audioRenderer, AssetManager assetManager, Node player) {
AudioNode threatDialog = new AudioNode(assetManager, "Sounds/threat-rich.ogg",false);
threatDialog.setLooping(false);
threatDialog.setPositional(true);
threatDialog.setLocalTranslation(player.getWorldTranslation());
threatDialog.setVolume(0.5f);
audioRenderer.playSource(threatDialog);
}
// in update I am calling above method to play the dialog
if (stop) {
…
playDialogs(audioRenderer,assetManager,playerModel);
}
[/java]
It is playing, but nothing is clear there. I can hear just a noise. (Like sound track playing in a lesser speed than expected.)
What would be the case? Where I have done wrong ? Please give me your opinion.
When I play the same clip with the sample example provided in the beginers tutorial, it is played nicely. At that time it is played for a mouse action.
Is this problem occurred as I play that in the simpleUpdate() method ? If so what is the trick I can used to achieve my target ?
try
if (stop) {
…
playDialogs(audioRenderer,assetManager,playerModel);
stop = false;
}
my guess is when stop is true it starts playing the sound again and again on every loop.
Thanks Nehon, that was the case.