MediaPlayer making APP not responding

痞子三分冷 提交于 2019-12-22 13:05:58

问题


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

来源:https://stackoverflow.com/questions/13749996/mediaplayer-making-app-not-responding

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!