Hello,
I’m trying to add audio to my game, but it claims that AudioNode has no method play(). Here is the relevant code:
[java]import com.jme3.audio.*;
background_music = new AudioNode(RenderData.getAssetManager(), “Sound/schumann.ogg”,true);
RenderData.getRootNode().attachChild(background_music);
background_music.setDirectional(false);
background_music.setPositional(false);
background_music.setLooping(true);
background_music.play();[/java]
Hi there!
I just wanted to ask about the same problem when i saw this post. Today i was playing around with the AudioNode class. At a point when i wanted to use play() and playInstance() methods, it appeared that these methods don’t exist. No matter where I’ve looked for solution to this problem it turned out that nobody had had any problems like these. The IDE just kept telling me: “No such methods in class AudioNode”.
I hope you guys know something about the problem…
Thanks in advance!
I havent checked it yet
but in my code I just saw audioRenderer.playSource(an AudioNode);
I dont know where I found my code, try to look at wiki/document or in testaudio
I think my code was born from both them
here is a small example
AudioNode abc= new AudioNode(assetManager,"/pathofyourfile/audio.ogg");
audioRenderer.playSource(abc);
It seems that xieu90 is right; you have to use the AudioRenderer.playSource() to play a sound. Although it does not appear in the online docs, after checking my local docs, they include an AudioRenderer class and no play() method on AudioNode.
Apparently, Application creates a default AudioRenderer for you, called audioRenderer.
Thanks everyone.
Then if it’s like that, why Tutorial (11) teaches us to play sounds calling either play() or playInstace() methods. Moreover in the online documentation of AudioNode class there is such methods: [java] void play() [/java]- Start playing the audio and [java]void playInstance() [/java]- Start playing an instance of this audio. (thinking). If there is some changes with the way sounds are played in JME3, perhaps the online docs and tutorials should be fixed.
Does anybody know anything ?
As stated in a big fat hint, the wiki is for the svn/nightly version and the manual inside the SDK is for the version that you actually have installed. The nightly version does in fact play the audio via the node and not via the audioRenderer.
Ah, ok thanks for the answers : ) Now i got it.
thanks all. I had this problem as well now its solved.
K Out!
Thanks to all who posted. I just encountered this same problem and could not figure out for the life of me how something so straightforward was so messed up.
Actually, jME3 beta now has the play() and playInstance() methods.
The beta version is more stable than the nightly version, so you’d be better off using that if you don’t need the very latest updates.
AudioNode has had play() for a very long time now. Almost a year now, I guess.
How old of a version are you using?
Looked it up… AudioNode got play and playInstance last April:
http://code.google.com/p/jmonkeyengine/source/detail?r=7334&path=/trunk/engine/src/core/com/jme3/audio/AudioNode.java
Just after alpha4, I guess. So yeah, almost a year.