I have an activity that's using a MediaPlayer to play video content. The activity simulates a TV device by playing different HLS video streams on key up/down presses. After watching some video for a longer time (approx. > 15 mins), when I press any key the APP is not responding and is getting to a Force Close screen. Here's what I'm doing on every key event up/down:
//I'm creating the media player object only once, after every channel switch i do:
if(mMediaPlayer.isPlaying()) {
mMediaPlayer.stop();
mMediaPlayer.reset();
}
try {
mMediaPlayer.setDataSource(app.channels.get(current_index).streaming_url);
mMediaPlayer.setDisplay(holder);
mMediaPlayer.setScreenOnWhilePlaying(true);
mMediaPlayer.prepareAsync();
}
catch(Exception e) {
e.printStackTrace();
}
//After this I have an onPreparedListener and mMediaPlayer.start()
My assumption is that it's eating the device's memory but I can't understand what I'm dowin wrong