How to locate the audio file after i media.stopRecord()


#1

Hey guy, i need to record audio in my app and after record upload it.

I’m doing things good by using cordova.capture. I can record audio and upload it.
But some android device, which did not have a default record UI, i can not use the capture function anymore. After i did some research, i should only use the phonegap media, use media.startRecord() and stopRecord(). By calling this two functions, i didn’t get any error.

var src = “myrecording.mp3”;

var mediaRec = new Media(src, function onSuccess( ){ }, function onError(error){ });

But after that, i want to locate the audio file, and upload it. And i use the src variable, it does’t work.
I have try cordova.file to locate the file and i check if my file in their, by using function

$cordovaFile.checkFile(“file:///android_asset/data/data//cache/”, “myrecording.mp3”)

it give me undefined error, also

$cordovaFile.checkFile(“file:///android_asset/data/data//files/”, “myrecording.mp3”)
$cordovaFile.checkFile(“file:///android_asset/data/data//files/Documents/”, “myrecording.mp3”)

Anyone same problem? How did you guys sloved it?

I would very appreciate for any help. Thank you very much!


#2

Tell me which plugin are you initially using to record your media?


#3

Hi Gajotres, i use plugin cordova.plugin.media to record audio in this situation.


#4

Finally i had solved this problem, with help: http://stackoverflow.com/questions/26858982/cordova-ionic-ngcordova-ios-or-iphone-file-read-error-code-5-encoding-err/27523006#27523006.

The file path for android are:

myFsRootDirectory1 = ‘file:///storage/emulated/0/’; // path for tablet
myFsRootDirectory2 = ‘file:///storage/sdcard0/’; // path for phone

Hope it can still help some other people.