Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24254] iOS: Audio recording functionality is not working.

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2016-12-22T05:50:22.000+0000
Affected Version/sRelease 6.0.0
Fix Version/sRelease 6.0.1
ComponentsiOS
Labelsn/a
ReporterMotiur Rahman
AssigneeHans Knöchel
Created2016-12-21T18:34:29.000+0000
Updated2018-08-06T17:49:25.000+0000

Description

Audio recording is not working with Ti SDK 6.0.0.GA but works as expected 5.5.1.GA Steps to Reproduce 1. Just run this code to the device and wait 10000ms time. 2. Add MicrophoneUsage permission to the tiapp.xml file. Test Code
var win = Ti.UI.createWindow({
	backgroundColor : "white"
});

var btn = Ti.UI.createButton({
    title: 'Trigger'
});

btn.addEventListener('click', trigger);

win.add(btn);
win.open();

function trigger() { 
    
    function startRecording() {
        Ti.API.info('Has permissions!')

        Titanium.Media.audioSessionCategory = Ti.Media.AUDIO_SESSION_CATEGORY_PLAY_AND_RECORD;
        var audioRecorder = Ti.Media.createAudioRecorder({
            compression : Ti.Media.AUDIO_FORMAT_AAC,
            format : Titanium.Media.AUDIO_FILEFORMAT_MP4
        });
 
        audioRecorder.start();
 
        setTimeout(function() {
            var stoppedFile = audioRecorder.stop();
 
            var fileName = "sosAudio.mp4";
            
 
            var audioFile = Ti.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory, fileName);
            audioFile.write(stoppedFile.toBlob);
 
            alert(audioFile.size);
 
        }, 3000);
    }
    
    if (!Ti.Media.hasAudioPermissions()) {
        Ti.Media.requestAudioPermissions(function(e) {
            if (e.success) {
                startRecording();
        	} else {
        		alert("please grant audio permissions.");
        	}

        });
    } else {
        startRecording();
    }
}

<key>NSMicrophoneUsageDescription</key>
                <string>Can we use your microphone?</string>

[ERROR] :  Script Error {
[ERROR] :      column = 372;
[ERROR] :      line = 1;
[ERROR] :      message = "+[NSBlock boundBridge:withKrollObject:]: unrecognized selector sent to class 0x1b4ffdd58";
[ERROR] :      sourceURL = "file:///var/containers/Bundle/Application/5707C951-4533-486D-9CE4-166F326F3B83/audioTest.app/app.js";
[ERROR] :      stack = "[native code]\nfile:///var/containers/Bundle/Application/5707C951-4533-486D-9CE4-166F326F3B83/audioTest.app/app.js:1:372";
[ERROR] :  }


Thanks

Comments

  1. Hans Knöchel 2016-12-21

    Hey [~morahman], I could reproduce the issue with 6.0.0.GA like stated here, but I could (luckily) not with 6.0.1 (6.0.1.v20161219165108, the one that will go GA today). Can you validate with that one again? And I also updated the test-case to be more solid, thx! *EDIT*: Yeah, I fixed it in [this commit](https://github.com/appcelerator/titanium_mobile/commit/3189bafc8898fe9b143611a1819fb44a90233815) as part of TIMOB-24140 (which is part of 6.0.1).
  2. Eric Merriman 2016-12-21

    Unable to reproduce with: NPM Version: 2.15.1 Node Version: 4.6.2 Mac OS: 10.11.2 Appc CLI: 6.1.0 Appc CLI NPM: 4.2.8 Titanium SDK version: 6.0.1.v20161217061750 Appcelerator Studio, build: 4.8.1.201612050850 Xcode 8.2 GM With 6.0.0 SDK the app would crash when clicking "trigger".
  3. Eric Merriman 2018-08-06

    Cleaning up older fixed issues. If this issue should not have been closed as fixed, please reopen.

JSON Source