[LibGDX] Play audio upon button press more than once.

This problem might seem a bit trivial, but I seem to be pulling my brain out along with my hairs trying to work this one out.

Basically, I have a “New Game” button, which once clicked, takes me to another screen which lets me choose story or custom game.
When I click the New Game button, it also plays an audio file, no problemo, however once in the other screen, I click “Back” to go back to the main menu and click the “New Game” button again, the game crashes with a nullPointerException.

I’ve been doing some digging online (as we do), and haven’t really found any solution other than other people’s custom audio loading classes, which I can learn off if I actually NEED to.
I have also looked at the LibGDX documentation about using an AssetManager (https://github.com/libgdx/libgdx/wiki/Managing-your-assets), which I believe is probably going to solve a few problems for me, more so than just this one.

What I am wondering is WHY I would be getting a nullpointerException when the audio plays fine the first time, but not the second.
What I am also wondering, is if I am heading in the right direction here?
Should I be using the AssetManager, or writing my own audio loading class and asset caching class? Because honestly without using someone elses code as reference, I would have no idea where to start with doing the latter.

As always, I am looking for direction, not a direct answer as I need to learn to problem solve and learn these things myself, not have it handed to me on a silver platter.

Any help would be greatly appreciated, I will continue to search for a solution or some insight as to WHY I would be getting a null pointer in this scenario.

EDIT: I have found this tutorial here which I think may be helpfuly.
I am thinking that once I play the audio, I need to store the ID into a Long variable type, and refer to that ID when I want to do something with it again, am I correct or no idea? :stuck_out_tongue:

When you leave the NewGameScreen, do you dispose of your assets?

This may or may not be the issue.

DOH!, thanks for reminding me!
I actually did dispose of the object in a different class, but had forgotten to dispose of this particular sound…le sigh!

Anyway, yay for progress. Now I don’t get an error, but if I try to play the sound again, nothing happens…I have a bit of an idea why, because once the audio is disposed of…ITS GONE, therefore, I am trying to play nothing, so I’m going to tinker a bit to try and get it working properly.

UPDATE:
Got it sorted now, however I believe I should be using the AssetManager in the long term, but for now, this is good for prototyping.

I have a class called MenuMusic which has a few methods inside of it. One of which is to play the button clicking noise. My problem was it wasn’t creating a newSound, when a new MenuMusic object was created, the new sound was created, but once disposed of, if I tried to play it, nothing would happen as it’s not there.
So the method to play the sound is what creates the newSound.

I’m too tired for this to even make sense, but I hope it does make sense.

Anyway Mz103, thankyou for reminding me of something so simple, yet so easily overlooked, I feel so stupid now haha.