捕捉音频的PhoneGap错误code 3 [英] Capture Audio Phonegap error code 3

查看:303
本文介绍了捕捉音频的PhoneGap错误code 3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建与录音的应用程序,我想实现这个例子code:
http://docs.phonegap.com/en/3.3.0/cordova_media_capture_capture.md.html#capture.captureAudio

I'm creating an app with audio recording, i tried to implement this example code: http://docs.phonegap.com/en/3.3.0/cordova_media_capture_capture.md.html#capture.captureAudio

但是,当点击该按钮出现的错误:code错误3.根据文档这样的错误,当你退出录制aplicacion录制任何东西之前,但是当我点击按钮没有启动录制程序出现它直接到错误的功能。

But when click on the button an error appears: Code error 3. According to documentation this errors appears when you exit the recording aplicacion before you record anything, but when i click on the button the recording app is not launched it goes directly to error function.

拍摄视频工作正常。

使用PhoneGap的3.0.0或2.9.0与PhoneGap的建设。

Using Phonegap 3.0.0 or 2.9.0 with Phonegap Build.

code:

<!DOCTYPE html>
<html>
<head>
<title>Capture Audio</title>

<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8" src="json2.js"></script>
<script type="text/javascript" charset="utf-8">

// Called when capture operation is finished
//
function captureSuccess(mediaFiles) {
    var i, len;
    for (i = 0, len = mediaFiles.length; i < len; i += 1) {
        uploadFile(mediaFiles[i]);
    }
}

// Called if something bad happens.
//
function captureError(error) {
    var msg = 'An error occurred during capture: ' + error.code;
    navigator.notification.alert(msg, null, 'Uh oh!');
}

// A button will call this function
//
function captureAudio() {
    // Launch device audio recording application,
    // allowing user to capture up to 2 audio clips
    navigator.device.capture.captureAudio(captureSuccess, captureError, {limit: 2});
}

// Upload files to server
function uploadFile(mediaFile) {
    var ft = new FileTransfer(),
        path = mediaFile.fullPath,
        name = mediaFile.name;

    ft.upload(path,
        "http://my.domain.com/upload.php",
        function(result) {
            console.log('Upload success: ' + result.responseCode);
            console.log(result.bytesSent + ' bytes sent');
        },
        function(error) {
            console.log('Error uploading file ' + path + ': ' + error.code);
        },
        { fileName: name });
}

</script>
</head>
<body>
    <button onclick="captureAudio();">Capture Audio</button> <br>
</body>

推荐答案

这是不是一个确切回答你的问题,而是一个工作的选择。

This is not an exactly answer to your problem, but a working alternative.

而不是使用的 org.apache.cordova.media捕获的的我试过 org.apache.cordova.media

Instead of using org.apache.cordova.media-capture I tried org.apache.cordova.media.

下面是一个小例子:

function recordAudio() {
    var src = "myrecording.amr";
    var mediaRec = new Media(src,
        // success callback
        function() {
            console.log("recordAudio():Audio Success");
        },

        // error callback
        function(err) {
            console.log("recordAudio():Audio Error: "+ err.code);
        });

    // Record audio
    mediaRec.startRecord();

    // Stop recording after 10 seconds
    setTimeout(function() {
        mediaRec.stopRecord();
    }, 10000);
}

Unfortunaly每个设备使用自己的声音codeC和Android中的情​​况下,它是AMR codeC。我能听使用 MPC(Windows)中备案。但是,如果你要上传的文件,并与其他用户一起分享,你必须其转换

Unfortunaly each device uses their own audio codec and in case of Android it is the AMR Codec. I was able to listen to the record using MPC (Windows). But if you want to upload the file and share it with other users, you'll have to convert it.

如果你没有找到 myrecording.amr 文件:它位于设备的根目录。我也没弄清楚如何临时存储在应用程序缓存文件夹本身,这是现有的文件。

If you do not find the myrecording.amr file: It is located on devices' root. I did not figure out how to store files temporary in the application cache folder itself, which is existing.

10秒的记录具有&LT; 20KB大小。

A 10 second recording has < 20kb size.

AMR 8000Hz mono 12kbps [Audio]

这是非常糟糕的质量。 Unfortunaly似乎有没有可能提高质量。

Which is very bad quality. Unfortunaly there seems to be no possibility to increase the quality.

这篇关于捕捉音频的PhoneGap错误code 3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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