You can reset, reuse, or release a MediaPlayer instance that you no longer need.
When you reset a MediaPlayer instance, it is returned to its uninitialized IDLE state as defined in MediaPlayerState.
This operation is useful in the following cases:
You want to reuse a
MediaPlayer instance but need to load a new
MediaResource (video content) and replace the previous instance.
Resetting allows you to reuse the
MediaPlayer instance without the overhead of releasing resources, recreating the
MediaPlayer, and reallocating resources.
MediaPlayer is in an ERROR state and needs to be cleared.
This is the only way to recover from the ERROR state.
reset to return the
MediaPlayer instance to its uninitialized state:
void reset() throws IllegalStateException;
MediaPlayer.replaceCurrentResource to load another
To clear an error, load the same
When you receive the
STATUS_CHANGED event callback with PREPARED status, start the playback.
You should release a MediaPlayer instance and resources when you no longer need the MediaResource.
When you release a
MediaPlayer object, the underlying hardware resources that are associated with this
MediaPlayer object are deallocated.
Here are some reasons to release a MediaPlayer:
MediaPlayerobject can lead to continuous battery consumption for mobile devices.
void release() throws IllegalStateException;
MediaPlayer instance is released, you can no longer use it. If any method of the
MediaPlayer interface is called after it is released, an
IllegalStateException is thrown.