edimuj / cordova-plugin-audioinput

This iOS/Android Cordova/PhoneGap plugin enables audio capture from the device microphone, by in near real-time forwarding audio to the web layer of your application. A typical usage scenario for this plugin would be to use the captured audio as source for a web audio node chain, where it then can be analyzed, manipulated and/or played.

Home Page:https://github.com/edimuj/app-audioinput-demo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ERROR fileUrl incorrect in IOS

MmSwd opened this issue · comments

commented

Hi
I started using this plugin with great satisfaction on Android; when I tried to use it on IOS, I had problems starting from the example for a simple audio recording.

var captureCfg = { fileUrl : cordova.file.cacheDirectory + "temp.wav" } // Start the capture. audioinput.start(captureCfg); // ...and when we're ready to stop recording. audioinput.stop();
When I try this example in IOS (version 10) , the log is:
[INFO] startRecording: 0
[INFO] stop: 0
[INFO] stopped: 0

In debug with xcode I saw that there is a line (105-106) in AudioReceiver.m
_fileUrl = [NSURL URLWithString:[url stringByAddingPercentEncodingWithAllowedCharacters:set]];

that transform my path from :

file:///var/mobile/Containers/Data/Application/0C07A5DE-32CD-4498-833A-BBAEC19025D0/Library/Caches/temp.wav

to

"file%3A%2F%2F%2Fvar%2Fmobile%2FContainers%2FData%2FApplication%2F0C07A5DE-32CD-4498-833A-BBAEC19025D0%2FLibrary%2FCaches%2Ftemp.wav"

so the file url is invalid.

I try to comment the line that convert with percent symbols, and using this line

        _fileUrl = [NSURL URLWithString:url];

now it Works!

Someone has the same problem?
Am I doing something wrong using the plugin?

commented

Hi @MmSwd, I too got the same issue "error: "Invalid file URL". I tried your fix by changing that one line of code so error is gone but I don't get the callback function 'onStopped' called after stop method call. Did you do any other change in plugin code?

Same problem here, no callback for audioinput.stop so no url...

I copied the plugin, linked it locally and swapped the line.

It seems you get the correct url when you subscribe to the "audioinputfinished" event.