And it comes with a bunch of API methods like startRecord() and stopRecord() that can operate on the media object. Once the user has finished recording, I can call the Play() method on the media object to playback the recording. All of this works fine for me, but I am not sure how to grab the actual audio file so I can post it ($http.post) to my server. Any help is appreciated.
OK so basically cordova-plugin-media creates a file somewhere in the device’s storage when recording (media.startRecord()), and I just need to use Cordova’s file handling plugin to get a hold of that file, right?
Not sure what platform you are using, but iOS tends to create the media files in the /tmp folder by default. Using the ‘documents://’ prefix on the file name make the Media plugin create the file in the AppData/Documents folder, which is more persistent.
Where you store the file depends on whether you want to keep it etc. But the real trick is locating the file afterwards so you can delete/move/upload it etc. iOS and Android have small differences in where they store the file, and hence how you locate it.
While we are at it, let me ask…once I get a hold of the file, is it as simple as just doing $http.post(url, file)? Do I need to do anything else, like encoding/content type/etc?
Hi I am also facing same problem
I am building app for android phone
where I am recording users email and dob and i want that two audio files to send to my server
on button click I am recording users voice but it is storing on sdcard which I don’t want I want to use phone storage
here is my code
var myMedia;
$scope.captureEmail = function () {
myMedia = new Media(“myemail.mp3”);
myMedia.startRecord();
};
$scope.stopRecord = function () {
myMedia.stopRecord();
};
$scope.playEmail = function () {
var myMedia = new Media("/sdcard/myemail.mp3");
myMedia.play();
};
Hi nice link could, i tried it startrecord works well but i could not make a playback, cam u tell me how to change file name or to get the path of audio file that is been created wit cordova-media-plugin