Quantcast
Channel: Appcelerator Developer Center Q&A Tag Feed (device)
Viewing all articles
Browse latest Browse all 250

Record Sound Not Working on Simulator or Device

0
0

Below is a snippet of code from my app. Most of which was taken directly from Kitchen Sink. I have tried multiple different solutions but nothing seems to be working. It does not work on the Simulator or a Device. What am I missing. The Kitchen Sink does not on Simulator or Device as well.

I need to take the audio and save it to file for later use. Please tell me what I am missing.

Thank you

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 = Titanium.Media.AUDIO_FILEFORMAT_MP3;
 
 
var b1 = Titanium.UI.createButton({
        title:'Start Recording',
        width:200,
        height:40,
        top:20
    });
    b1.addEventListener('click', function()
    {
        if (recording.recording)
        {
            file = recording.stop();
            b1.title = "Start Recording";
            b2.show();
            pause.hide();
            clearInterval(timer);
            Ti.Media.stopMicrophoneMonitor();
        }
        else
        {
            if (!Ti.Media.canRecord) {
                Ti.UI.createAlertDialog({
                    title:'Error!',
                    message:'No audio recording hardware is currently connected.'
                }).show();
                return;
            }
            b1.title = "Stop Recording";
            recording.start();
            b2.hide();
            pause.show();
            Ti.Media.startMicrophoneMonitor();
            duration = 0;
            timer = setInterval(showLevels,1000);
        }
    });
    win.add(b1);

Viewing all articles
Browse latest Browse all 250

Latest Images

Trending Articles





Latest Images