本文介绍了setVideoURI 导致致命信号 6(SIGABRT)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在测试我不久前创建的一个旧应用.该应用程序正在使用光纤 WiFi,但如果我使用正常的 3G 连接,该应用程序会因信号 6 VM 错误而崩溃.尝试隔离问题,发现是setVideoURI方法造成的.

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.

这是我的代码:

    @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);
      }

这个问题似乎只存在于我的 Moto G 4.4.4 上.这是一个已知的问题?有解决方法吗?

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

推荐答案

VideoView.setVideoURI() 启动了一个新的媒体播放线程,但是导致额外延迟的是媒体解码部分.所以尝试在单独的线程上运行该方法.

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();
}

这篇关于setVideoURI 导致致命信号 6(SIGABRT)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-07 16:29