In the Android docs, there is a constant defined MEDIA_ERROR_SERVER_DIED
which is described as:
Media server died. In this case, the application must release the MediaPlayer object and instantiate a new one.
This seems very vague. What does it mean that the Media server died? Why would it die? And is it proper to handle it by immediately trying to play again afterwards?
MediaPlayer class can be used to control playback of audio/video files and streams.
mediaPlayer. start(); mediaPlayer. pause(); On call to start() method, the music will start playing from the beginning.
MediaPlayer Class in Android is used to play media files. Those are Audio and Video files.
In Android, most of media activity (decoding/encoding) happens in the mediaserver, except in limited cases, such as local file playback using software codec. Android mediaserver routinely crashes (aborts) on hardware errors, incorrectly formatted files or data. Yeah, sorry!
Since many activities share a common mediaserver, an error in any of the activities can crash mediaserver. This most commonly happens when a background activity, such as media scanner or Google+ Auto-Awesome Movies tries to scan a corrupt or just unsupported file. When this happens, the remaining processes that used mediaserver receive a notification. This notification is passed to the app in case of MediaPlayer or MediaRecorder.
When mediaserver dies, it is immediately restarted. Even though the server dies, the proxy object on the application is still alive and is using resources. Hence the need to release the object. It should be safe to create a new one immediately after the notification.
One condition that causes this is when the MediaPlayer doesn't receive or stops receiving the video stream from the server. If the error consistently occurs immediately (i.e. if none of the video is received at all), you may want to ensure that nothing (firewall, VPN, etc.) is blocking your route to the server.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With