Android AudioFlinger server died | media server died

早过忘川 提交于 2019-12-06 13:18:25

I think it's just what it says: network issues have made the MediaPlayer think the server closed the connection.

For HTTP streaming, I would suggest sticking a simple proxy server on the device so that you have a bit more control over the data that gets sent to the player. The Apache libraries are pretty easy to use by themselves, or you can pick up a lightweight wrapper like Naga. You can make reconnect requests at the exact byte you left off in case of errors like this. There are other benefits, like being able to cache data if so desired, but being in control of the remote communication provides a level of freedom you won't otherwise find with the MediaPlayer.

Note for future reference: this answer wasn't good for HLS. See the comments.

Check your error listener for Error(100,0). Release the player don't just reset it and recreate another object.

One reason is multi-threaded access to the MediaPlayer service which uses the AudioService. Another -which is probably your case- is memory issues. try to minimize number of players running together and pay close attention to how much memory your app is using.

Here is how to detect Error(100,0):

mMediaPlayer.setOnErrorListener(new MediaPlayer.OnErrorListener() {
        public boolean onError(MediaPlayer mp, int what, int extra) {
            mMediaPlayer.release();
            //create another mediaplayer preferrably in another thread
            return false;
        }
    });
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!