Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Audio Session Crashing App

$
0
0

Hi All

I have been working developing various audio based mobile apps and i always seems to hit the same issue when using a audio session, if someone could please advise me that would help.

First i am using the latest titanium SDK 3.2.2 GA running on IO7

My app is working with a tab group and when the first tab loads i have a audio recorder like below that sets the audio session to Record

var currentSessionMode = Titanium.Media.audioSessionMode;
Titanium.Media.audioSessionMode = Ti.Media.AUDIO_SESSION_MODE_PLAY_AND_RECORD;
recording = Ti.Media.createAudioRecorder();
This work find records my audio and i save it on the phone then i have another tab which displays all the audio recordings and i play with a video player like this.
Titanium.Media.audioSessionMode = Ti.Media.AUDIO_SESSION_MODE_PLAYBACK;
var videoPlayer = Titanium.Media.createVideoPlayer({
        bottom : 0,
        autoplay : false,
        backgroundColor : '#fff',
        height : 40,
        width : '100%',
        mediaControlStyle : Titanium.Media.VIDEO_CONTROL_DEFAULT,
        scalingMode : Titanium.Media.VIDEO_SCALING_ASPECT_FIT
});
videoPlayer.url = model.url.nativePath;
self.add(videoPlayer);
Should i be changing the audio session mode this way throughout the app? because if i go back to record again i get this error.
Error: AudioQueueStart failed (-50)
I have added a bounty for this on stackoverflow here http://stackoverflow.com/questions/20300526/ios-7-iphone-recording-app-error-audioqueuestart-failed-50

And i have had a response about a possible solution for the fix which is below.

Just add this code before calling any AudioQueue function:

AudioSessionInitialize(NULL,
                       NULL,
                       nil,
                       ( void *)(self)
                       );
 
UInt32 sessionCategory = kAudioSessionCategory_PlayAndRecord;
AudioSessionSetProperty(kAudioSessionProperty_AudioCategory,
                        sizeof(sessionCategory),
                        &sessionCategory
                        );
 
AudioSessionSetActive(true);
But i am not sure where i would go about adding this to the titanium sdk i have look through all the audio classes in the sdk comfortable changing anything.

Could anyone help with this.

Thanks


Viewing all articles
Browse latest Browse all 8068

Trending Articles