开发者

Is it possible to have AVFramework and AudioToolbox framework in one app?

I'm trying to write develop audio related application. In that, I'm using AudioToolBox framework for recording the sound. And I'm using AVFramework to play soudns. When app is stared, it will play some mp3 file using AVFramework. And also initializes Audiotoolbox. In simulator, I'm able to record and play. But when I'm testing it on iPhone, I'm getting following error for initializing AudioToolBox.

2009-12-11 22:25:51.599 StoryBook[807:207] AudioRecorder init AudioSessionIni开发者_运维百科tialize failed with error: 1768843636

Can some one tell me whether we can use both AV as well as Audio Toolbox frame works in one application? Why I'm getting that error?


In my experience this return code:

2009-12-11 22:25:51.599 StoryBook[807:207] AudioRecorder init AudioSessionInitialize failed with error: 1768843636

is a symptom of AudioSessionInitialize called more than once inside the app.

This is somehow warned in the documentation when they write:

Your application must call this function before making any other Audio Session Services calls. You may activate and deactivate your audio session as needed (see AudioSessionSetActive), but should initialize it only once.


If you want to record and play at the same time, you should change your audio session category. By default it allows you only to play sound.

NSError* err;
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord error:*err];


Use AVAusioSession to manage your session and don't call AudioSessionInitialize manually.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜