Hi All,
I constantly get a error with audio recordings i have spent so much time on this tried so many different solution but i just constantly get errors its a nightmare.
Here is my code.
/* * setup recording */ var self = Ti.UI.currentWindow; // SETUP AUDIO STUFF var currentSessionMode = Titanium.Media.audioSessionMode; Titanium.Media.audioSessionMode = Ti.Media.AUDIO_SESSION_MODE_PLAY_AND_RECORD; var recording = Ti.Media.createAudioRecorder(); recording.format = Ti.Media.AUDIO_FILEFORMAT_MP4; recording.compression = Ti.Media.AUDIO_FORMAT_AAC; Ti.Media.addEventListener('recordinginput', function(e) { if (!e.available && recording.recording) { recBtn.fireEvent('click', {}); } }); var recBtn = Ti.UI.createImageView({ width : 201, height : 201, backgroundColor : 'transparent', backgroundImage : '/images/download_button.png', zIndex : 2 }); recBtn.addEventListener('click', function(evt) { if (recording.recording) { stopTimer(); file = recording.stop(); Ti.Media.stopMicrophoneMonitor(); } else { if (!Ti.Media.canRecord) { Ti.UI.createAlertDialog({ title : 'Error!', message : L('noAudio') }).show(); return; } else { Ti.Media.requestAuthorization(function(e) { if (e.success) { recording.start(); Ti.Media.startMicrophoneMonitor(); startTimer(); } else { alert('Access to Recorder is not allowed'); } }); } } }); self.add(recBtn); var stopClock = Titanium.UI.createLabel({ backgroundColor : 'transparent', text : '00:00:00:000', textAlign : Ti.UI.TEXT_ALIGNMENT_CENTER, bottom : 20, font : { fontSize : 42, fontFamily : 'HelveticaNeue-UltraLight' }, color : '#000000', width : Ti.Platform.displayCaps.platformWidth, height : Ti.UI.SIZE }); self.add(stopClock); function pad(num, size) { var s = "0000" + num; return s.substr(s.length - size); } function formatTime(time) { var h = m = s = ms = 0; var newTime = ''; h = Math.floor(time / (60 * 60 * 1000)); time = time % (60 * 60 * 1000); m = Math.floor(time / (60 * 1000)); time = time % (60 * 1000); s = Math.floor(time / 1000); ms = time % 1000; newTime = pad(h, 2) + ':' + pad(m, 2) + ':' + pad(s, 2) + ':' + pad(ms, 3); return newTime; }; function startTimer() { clocktimer = setInterval(function() { stopClock.text = formatTime(x.time()); Ti.API.info(recording.recording); }, 100); x.start(); }; function stopTimer() { x.stop(); clearInterval(clocktimer); strun = false; }; function resetTimer() { stopTimer(); x.reset(); stopClock.text = formatTime(x.time()); clearInterval(meter); }; var clsStopwatch = function() { // Private vars var startAt = 0; // Time of last start / resume. (0 if not running) var lapTime = 0; // Time on the clock when last stopped in milliseconds var now = function() { return (new Date()).getTime(); }; // Public methods // Start or resume this.start = function() { startAt = startAt ? startAt : now(); }; // Stop or pause this.stop = function() { // If running, update elapsed time otherwise keep it lapTime = startAt ? lapTime + now() - startAt : lapTime; startAt = 0; // Paused }; // Reset this.reset = function() { lapTime = startAt = 0; }; // Duration this.time = function() { return lapTime + ( startAt ? now() - startAt : 0); }; }; var x = new clsStopwatch(); function lineTypeToStr() { var type = Ti.Media.audioLineType; switch(type) { case Ti.Media.AUDIO_HEADSET_INOUT: return L('headset'); case Ti.Media.AUDIO_RECEIVER_AND_MIC: return L('receiverMic'); case Ti.Media.AUDIO_HEADPHONES_AND_MIC: return L('headphonesMic'); case Ti.Media.AUDIO_HEADPHONES: return L('headphones'); case Ti.Media.AUDIO_LINEOUT: return L('lineout'); case Ti.Media.AUDIO_SPEAKER: return L('speaker'); case Ti.Media.AUDIO_MICROPHONE: return L('microphone'); case Ti.Media.AUDIO_MUTED: return L('silence'); case Ti.Media.AUDIO_UNAVAILABLE: return L('unavailable'); case Ti.Media.AUDIO_UNKNOWN: return L('unknown'); } }; self.open();I just get a red bar drop down at the top and the recording fails if i run in xcode the error is.
Error: AudioQueueStart failed ('hwiu') [DEBUG] operation: 5, args: ( 20 ), size: 320.000000x320.000000 [DEBUG] operation: 4, args: ( fb5557 ), size: 320.000000x320.000000 [DEBUG] operation: 16, args: ( 160, 160, 100, 0, "0.1832924824612257", 0 ), size: 320.000000x320.000000Please help with a solution for this i am using 3.4.0 latest xcode but i have had issues with this from the start.