0

I write some code in response when my player is hit by the monster in my game. when monster hit my player, it will shout.

It is fine at begin but when the sound plays too much time or too frequently, the sound shut down and so as my background music. Can any one help me about this.

Here is my code about the shout sound:

public void createMusic()
{

    try {
        MusicFactory.setAssetBasePath("mfx/");
        wallmusic = MusicFactory.createMusicFromAsset(engine.getMusicManager(), activity, "speed.ogg");
        wallmusic.setLooping(false);

    } catch (final IOException e) {
        Debug.e(e);
    }   
      if (!wallmusic.isPlaying()){
      wallmusic.seekTo(0); 
      wallmusic.play(); 
      }
}

and the log says:

05-11 18:32:22.844: E/MediaPlayer(29575): error (-19,0)

05-11 18:32:22.844: E/MediaPlayer(29575): Error (-19,0)

05-11 18:32:22.844: E/MediaPlayer(29575): pause called in state 0

05-11 18:32:22.844: E/MediaPlayer(29575): error (-38,0)

05-11 18:32:22.844: E/MediaPlayer(29575): Error (-38,0)

How do I fix this problem?

1 Answers1

0

You have to put wallmusic.release() somewhere in your code to release memory otherwise this error will occure.

farhad.kargaran
  • 2,233
  • 1
  • 24
  • 30