So i have the following code. When no sound is playing in my app and the following is called the application crashes. From my knowledge it should skip the if statement if there is no sound playing…So why is it crashing?
public void IfSoundPlayingThenStop()
if (currentSound.isPlaying())
{
currentSound.release();
}
The simplest possible solution, if you just don’t care about the occasional null and would prefer to ignore them:
Otherwise, do a separate
if(currentSound == null)check before making any other use of the variable, and handle things as necessary.