Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

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

— asked April 19th 2010 by Ian Jestice
  • audio
  • createaudiorecorder
  • recorder

2 Answers

  • Accepted Answer


    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.

    — answered April 19th 2010 by Kosso
  • how about for Android – this doesn't work….

    — answered July 6th 2011 by Brian Dittmer
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.