Hello, I want to record an audio file (5 seconds of voice message), then store it on my device as a file and create at the same time a key of an object that I store in Properties, that let me retrieve the sound at a later time.
With this code I should record:
recordBtn.addEventListener("click", function(e) { var currentSessionMode = Titanium.Media.audioSessionMode; Titanium.Media.audioSessionMode = Ti.Media.AUDIO_SESSION_MODE_PLAY_AND_RECORD; var recording = Ti.Media.createAudioRecorder(); recording.compression = Ti.Media.AUDIO_FORMAT_ULAW; recording.format = Ti.Media.AUDIO_FILEFORMAT_WAVE; recording.start(); Ti.Media.startMicrophoneMonitor(); var rec = Titanium.Filesystem.getFile(getScrollableViewStatus() + '.wav'); // setTimeout(function() { var recordedFile = recording.stop(); rec.write(recordedFile); var currentKey = getScrollableViewStatus(); var currentValue = rec.nativePath; var obj = Ti.App.Properties.getObject("sounds")||{}; var tempObj = obj; tempObj[currentKey] = currentValue; Ti.App.Properties.setObject("sounds", tempObj); // test play var o2 = Titanium.App.Properties.getObject("sounds"); var k = o2[currentKey]; var fileToPlay = Titanium.Filesystem.getFile(k); var sound = Titanium.Media.createSound({ url : fileToPlay }); sound.play(); // }, 5000); });At the moment this fails without returning any kind of error. Could you help me understand what I'm doing wrong?