The following code is the processing code in the Android music:
Copy Code code as follows:
Mediaplayer.onerrorlistener Errorlistener = new Mediaplayer.onerrorlistener () {
public Boolean onError (MediaPlayer MP, int what, int extra) {
Switch (what) {
Case Mediaplayer.media_error_server_died:
Misinitialized = false;
Mcurrentmediaplayer.release ();
Mcurrentmediaplayer = new Compatmediaplayer ();
Mcurrentmediaplayer.setwakemode (Mediaplaybackservice.this, Powermanager.partial_wake_lock);
Mhandler.sendmessagedelayed (Mhandler.obtainmessage (server_died), 2000);
return true;
Default
LOG.D ("multiplayer", "Error:" + What + "," + extra);
Break
}
return false;
}
};
In simple terms, it is when you encounter MediaServer died that you release the original MediaPlayer and recreate a MediaPlayer (which is associated after the MediaServer reboot). Then you can do the corresponding action according to the original state.