Ionic2 - Record audio: how to set MediaPlugin path?

Hi, i’m new on Ionic/Cordova. I’m with Ionic 2. I want to test the recording feature accessing the device microphone, but i don’t understand this:

var file = new MediaPlugin(‘path/to/file.mp3’);

If I have to record my voice with microphone, i expect the app create a new audio file (.wav, . mp3 or what else). I don’t understand if file.mp3 is an already created file, and how i have to set the path? When i’m on a real device, where my record audio file is saved? is iOS/Android different (so i have to write 2 different code/path)?
Someone can show me a very simple working example? thanks

3 Likes

can anybody help me? i tried but i can’t figured out how it works

Did you solve your problem?
I have same problem, too.
I hope for your help.

Path can be tricky, you have to use cordova.file.externalDataDirectory on android, and u can find the file what have you created on the phone under Android/data/yourapplication/files folder.

If you use a wrong path, the file will be created on the mobile storage with a name similar to temprecording-xxxx...3gp.