PhoneGap的视频采集崩溃 [英] Phonegap video capture crashes

查看:517
本文介绍了PhoneGap的视频采集崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了一个比较简单的PhoneGap的应用程序,以捕捉图像和视频并将其上传到服务器的能力。

I've made a relatively simple phonegap app, with the ability to capture images and videos and upload them to a server.

图片做工精细,但是当我打电话给捕获视频的用户界面显示的摄像头,并且当我接受了视频应用程序崩溃了,在logcat中此错误:

Images work fine, however when I call to capture video the camera UI appears, and when I accept the video the app crashes out with this error in logcat:

java.lang.RuntimeException: Failure delivering result ResultInfo(who=null, request=2, result=-1, data=Intent { dat=content://media/external/video/media/46536 }} to activity {myApp.test.app}: java.lang.IllegalStateException:Do not perform IO operations on the UI thread. Use CordovaInterface.getThreadPool() instead

我使用PhoneGap的3.0.0,我已经安装了通过命令行界面正确的插件,我AndroidManifest是好的。

I'm using phonegap 3.0.0, I've installed the correct plugins via the commandline interface, and my AndroidManifest is fine.

我使用的是从PhoneGap的API演示code,所以这个问题是不存在任何

I'm using the demo code from the phonegap API, so the problem isn't there either.

推荐答案

一个解决此问题的方法是编辑[yourApp] \插件\ org.apache.cordova.media捕获的\ src \机器人\ Capture.java

A workaround for this issue is to edit [yourApp]\plugins\org.apache.cordova.media-capture\src\android\Capture.java

始于线377,改变这个code

Starting at line 377, change this code

private JSONObject createMediaFile(Uri data) {
    File fp = webView.getResourceApi().mapUriToFile(data);
    JSONObject obj = new JSONObject();

以下code

to the following code

private JSONObject createMediaFile(Uri data) {
    // is thread checking enabled?
    boolean thC = webView.getResourceApi().isThreadCheckingEnabled();       
    // set thread checking to disabled (this works around mapUriToFile failing with IllegalStateException: Do not perform IO operations on the UI thread.
    webView.getResourceApi().setThreadCheckingEnabled(false);       
    File fp = webView.getResourceApi().mapUriToFile(data);
    // set thread checking back to whatever it was before the call above.
    webView.getResourceApi().setThreadCheckingEnabled(thC);
    JSONObject obj = new JSONObject();

这为我们工作,希望这将是正确的尽快解决。

This worked for us, hopefully it will be fixed properly soon.

这篇关于PhoneGap的视频采集崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆