I am writing an app that streams videos from the network using MediaPlayer and SurfaceView. All is working fine most of the time but I've noticed that after some repeated app restarts and debugging I am not able to stream anymore files.
I close and restart the app, rebuild and run, closing and uninstalling it from the device.. nothing helps. When the issue happens I am getting this error from the MediaPlayer (Unknown error):
E/MediaPlayer﹕ error (1, -2147483648)
The only thing that let me return to normal behaviour so that everything is working and the streaming is good is restarting the device. No code change and no other steps, just restart and re-run the app (not ever re-installing it..)
Creating the MediaPlayer object as follow:
mMediaPlayer = new MediaPlayer();
mMediaPlayer.setDisplay(mSurfaceHolder);
mMediaPlayer.setDataSource(getContext(), mVideoUrl);
mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mMediaPlayer.setLooping(mRunLopping);
mMediaPlayer.setScreenOnWhilePlaying(true);
mMediaPlayer.setOnPreparedListener(this);
mMediaPlayer.setOnErrorListener(this);
mMediaPlayer.prepareAsync();
Maybe something with global device resources? caching? any clue will help.