How to I name an audio file that is created from createAudioRecorder
I'm trying to use createAudioRecorder to make an audio recording. I can't see how to name the audio file created.
In the KitchenSink tutorial, it appears that the example plays the file it created, but I can't see how a file can be named.
Any suggestions?
Ian J
2 Answers
-
Accepted Answer
Hi,
After the recorder stops, you have the file reference
var file = recording.stop();
You can then get the path to this file using:
var f = Ti.Filesystem.getFile(file.path);
Now, let's say you are recording an .m4a file which you want to be called 'newrecording.m4a' and you want to save it in the applicationDataDirectory …
You can then use the fileSystem move() command to copy if where you want to be and name it accordingly:
eg:
var m = f.move(Ti.Filesystem.applicationDataDirectory + '/newrecording.m4a');
If this works, the value of 'm' should be true.
One thing to note, is that if you are using the same filename over again, you should check for the existence of the old file first and delete it before trying to move the file.
Hope this helps.
-
how about for Android – this doesn't work….