Reset or reuse a MediaPlayer instance

Resetting a MediaPlayer instance returns it to its uninitialized state, which is called IDLE in MediaPlayer.PlayerState.

Resetting a MediaPlayer instance is useful in the following cases:
  • When you want to reuse a MediaPlayer instance but need to load a different MediaResource (video content). Resetting allows you to reuse the MediaPlayer instance without the overhead of releasing resources, recreating the MediaPlayer, and reallocating resources. The replaceCurrentItem method automatically does these steps for you, without having to call the reset method.
  • When the MediaPlayer is in an ERROR state and needs to be cleared. This is the only way to recover from the ERROR state.
  1. Call reset to return the MediaPlayer instance to its uninitialized state:
    void reset() throws IllegalStateException;
    
  2. Use MediaPlayer.replaceCurrentItem to load another MediaResource (or, in the case of clearing an error, the same MediaResource).
  3. When you receive the PlaybackEventListener.onPrepared callback, you can start the playback.