cordova-plugin-audioinput icon indicating copy to clipboard operation
cordova-plugin-audioinput copied to clipboard

ERROR fileUrl incorrect in IOS

Open MmSwd opened this issue 5 years ago • 3 comments

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?

MmSwd avatar Jul 02 '19 10:07 MmSwd

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?

pgcan avatar Jul 26 '19 11:07 pgcan

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

Merwan1010 avatar Sep 15 '19 18:09 Merwan1010

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.

dhandarbeit-tk avatar Sep 27 '19 14:09 dhandarbeit-tk