Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does MEDIA_ERROR_SERVER_DIED mean?

Tags:

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?

like image 884
yydl Avatar asked Dec 02 '11 06:12

yydl


People also ask

What does MediaPlayer release do?

MediaPlayer class can be used to control playback of audio/video files and streams.

What method is used to call media?

mediaPlayer. start(); mediaPlayer. pause(); On call to start() method, the music will start playing from the beginning.

Which class keeps a record of media player's state and what is currently being played?

MediaPlayer Class in Android is used to play media files. Those are Audio and Video files.


2 Answers

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.

like image 174
Lajos Molnar Avatar answered Sep 21 '22 16:09

Lajos Molnar


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.

like image 32
Rod Avatar answered Sep 21 '22 16:09

Rod