Capturing and playing audio via the audio recorder
Another handy feature of iPhones and most Android handsets is the ability to record audio data—perfect for taking audible notes during meetings or those long, boring lectures! In this recipe, we are going to capture some audio using the Ti.Media.AudioRecorder
class, and then allow the user to play back the recorded sound file.
As usual, the complete source code for this recipe can be found in the /Chapter 4/Recipe 6
folder.
Note
Note that this recipe is designed to work on iPhones, so you will also require a physical device. In addition, iPhone 3G models may not be capable of recording in some of the compression formats particularly high-fidelity formats, such as AAC. When in doubt, you should try using the MP4A or WAV format.
How to do it...
Type the following code in your app.js
file just after the definition of win3
and save.
This will set up the interface with a set of buttons and labels so that we can start, stop, and play back our recorded...