Skip to content Skip to sidebar Skip to footer

Mediaplayer Error Once Used Multiple Times

I've created a game which is nearly complete, but I've still got one problem: Once I press a button I want a sound to play, I did this with this code: MediaPlay

Solution 1:

Go for sound pool, or reuse one instance of media player, or release each instance once you have finished with it.

When done with the MediaPlayer, you should call release(), to free the resources. If not released, too many MediaPlayer instances will result in an exception.

etc

It is also recommended that once a MediaPlayer object is no longer being used, call release() immediately so that resources used by the internal player engine associated with the MediaPlayer object can be released immediately. Resource may include singleton resources such as hardware acceleration components and failure to call release() may cause subsequent instances of MediaPlayer objects to fallback to software implementations or fail altogether. Once the MediaPlayer object is in the End state, it can no longer be used and there is no way to bring it back to any other state.

See the documentation: http://developer.android.com/reference/android/media/MediaPlayer.html

Post a Comment for "Mediaplayer Error Once Used Multiple Times"