MediaPlaying seeking UI lag

大憨熊 提交于 2019-12-25 03:23:45

问题


I have made a VideoPlayer using MediaPlayer which renders on surfaceView. For controls I am using "VideoControllerView". The problem is when I seek the progressbar, the UI becomes unresponsive and I get ANRs. As far as my knowledge is, nothing heavy is running on UI thread unless MediaPlayer updates/renders surfaceView on UI thread, in that case seeking might cause this issue. What factor here contributes to unresponsive UI on seeking? And how to check what is running on UI thread?

public void onCreate()
{
  ....
    SurfaceHolder holder = surfView.getHolder();
    holder.addCallback(this);

    mMediaPlayer = new MediaPlayer();

  ....
}

@Override
public void surfaceCreated(SurfaceHolder holder) {

    mMediaPlayer.setDisplay(holder);

    try {
        mMediaPlayer.setDataSource(usedURL);

        mMediaPlayer.prepareAsync();

    } catch (IllegalArgumentException e) {

        e.printStackTrace();
    } catch (SecurityException e) {
        e.printStackTrace();
    } catch (IllegalStateException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

}

来源:https://stackoverflow.com/questions/28194187/mediaplaying-seeking-ui-lag

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