setVideoURI causes fatal signal 6(SIGABRT)

心不动则不痛 提交于 2019-12-11 02:32:17

问题


I'm testing an old app I created a while ago. The app is working on fiber WiFi, but if I use normal 3G connection the app crashes with a signal 6 VM error. I tried isolating the problem, I found out that it is caused by the setVideoURI method.

Here is my code:

    @Override
    protected void onPostExecute(Void result) {
        // TODO Auto-generated method stub
        super.onPostExecute(result);

        if (videourl != null && videourI != null
                && extracted.contains(".mp4")) {
            videoview.setOnPreparedListener(MainActivity.this);
            mc = new MediaController(MainActivity.this);
            mc.setMediaPlayer(videoview);
            videoview.setVideoURI(videourI);
            videoview.start();
            save.setOnClickListener(MainActivity.this);
      }

The problem seems to exist only on my Moto G with 4.4.4. Is this a known issue? And is there a workaround?


回答1:


VideoView.setVideoURI() starts a new thread for media playback, but it is the media decoding part which causes extra delay. so try to run that method on seperate Thread.

if (videourl != null && videourI != null && extracted.contains(".mp4"))
{
    videoview.setOnPreparedListener(MainActivity.this);
    mc = new MediaController(MainActivity.this);
    mc.setMediaPlayer(videoview);
    new Thread(new Runnable()
    {
        @Override
        public void run()
        {
            videoview.setVideoURI(videourI);  // make videoView final
            runOnUiThread(new Runnable()
            {
                @Override
                public void run()
                {
                    videoview.start();
                    save.setOnClickListener(MainActivity.this);
                }
            });
        }
    }).start();
}


来源:https://stackoverflow.com/questions/26616513/setvideouri-causes-fatal-signal-6sigabrt

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