hsnbsn / jmonkeyengine

Automatically exported from code.google.com/p/jmonkeyengine
0 stars 0 forks source link

[Nifty-GUI Integration] SoundHandleJme sets node to null in stop() which will lead to a NPE when play() is called #511

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Register a sound to be played with Nifty, f.i. in XML do:

<registerSound id="myclick" filename="Interface/b.ogg" />

2. Call play(), stop(), play() on the SoundHandle:

SoundHandle soundHandle = nifty.getSoundSystem().getSound("myclick");
soundHandle.play();
soundHandle.stop();
soundHandle.play();

3. The last call to play() will crash with a NPE

java.lang.NullPointerException
    at com.jme3.niftygui.SoundHandleJme.play(SoundHandleJme.java:83)
...

What is the expected output? What do you see instead?

It should be possible to play() a sound again after calling stop(). If this is 
not possible because the AudioNode uses a streaming audio source the play() 
method should reset/reload the stream.

Original issue reported on code.google.com by void65...@googlemail.com on 13 Jun 2012 at 10:08

GoogleCodeExporter commented 9 years ago
I might add that it works correctly when the SoundHandleJme is instantiated for 
"music" instead of "sound" in the SoundDeviceJme.

This is because when being used for "music" this constructor is being called:

  public SoundHandleJme(AudioRenderer ar, AssetManager am, String fileName);

instead of this one:

  public SoundHandleJme(AudioRenderer ar, AudioNode node);

when being used as a "sound".

The problem is probably the:

  if (fileName != null){

in the play() method.

Original comment by void65...@googlemail.com on 13 Jun 2012 at 10:23

GoogleCodeExporter commented 9 years ago

Original comment by ShadowIs...@gmail.com on 10 Nov 2012 at 9:08