0

I am trying to use the audio recording as described in the PhoneGap API documentation. But on IOS there seems to be a problem with the file URI for myrecording.wav. I am using the following code to write to a file named myrecodring.wav

function recordAudio() {
        var src = "myrecording.wav";
        var mediaRec = new Media(src, onSuccess, onError);

        // Record audio
        mediaRec.startRecord();

        // Stop recording after 10 sec
        var recTime = 0;
        var recInterval = setInterval(function() {
            recTime = recTime + 1;
            setAudioPosition(recTime + " sec");
            if (recTime >= 10) {
                clearInterval(recInterval);
                mediaRec.stopRecord();
            }
        }, 1000);
    }

i've also tried file://myrecording.wav and file:///myrecording.wav i've done my test on ios5 iphone 4gs. I get the failure message with code 1 saying "Cannot use audio file from resource...."

Thanks for you help, Martin

1 Answer 1

0

You have to first get file system:

window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);

Then get the file:

function gotFS(fileSystem) {
    alert('got FS');
    fileSystem.root.getFile("myrecording4.wav", {create: true, exclusive: false}, gotFileEntry, fail);
}

Now you can get the file URI:

function gotFileEntry(fileEntry) {
        alert('File URI: ' + fileEntry.toURI());
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.