如何恢复记录后中断的iphone发生? [英] how to resume recording after interruption occured in iphone?

查看:339
本文介绍了如何恢复记录后中断的iphone发生?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的录音机应用程序时,它工作完全正常。

I am working on an audio recorder application, it is working perfectly fine.

但我坚持与中断的问题。当有电话打进来,

But I'm stuck with the problem of interruption. When a call comes,

- (void)audioRecorderBeginInterruption:(AVAudioRecorder *)recorder

那么这个方法被调用,记录已暂停。

then this method is called and the recording is paused.

如果用户拒绝呼叫:

- (void)audioRecorderEndInterruption:(AVAudioRecorder *)recorder

然后在这里我想从它被中断的点继续录制。
但是,当我再次拨打该记录方法,记录开始于一个新的文件。

Then here I want to resume the recording from the point where it was interrupted. But when I call the record method again, the recording starts with a new file.

推荐答案

这个问题就解决了​​!

The problem is solved!

我已经重新写在记录code键避免这个问题。我用AudioQueues,基本上后端code是相同的与一些小的改动SpeakHere应用。它提供了两个以上的API:

I have re-written the recording code to avoid this problem. I used AudioQueues, basically the backend code is the same of SpeakHere application with some minor changes. Provided two more apis in it:

-(void)resume
{
    AudioQueueStart(queueObject, NULL);
}

-(void)pause
{
    AudioQueuePause(queueObject);
}

在AudioRecorder类。其基本目的是为了避免在记录方法做了录像设置。

In AudioRecorder class. The basic purpose being to avoid the recording setup which is done in record method.

设置中断回调,然后用这个暂停并在回调适当恢复方法。也照顾根据您的​​应用程序是否需要或不设置活动音频会话。

Setup the interrupt callback and then use this pause and resume methods appropriately in the callback. Also take care to set active the audio session based on whether your application needs it or not.

希望这有助于有人在那里。

Hope this helps someone out there.

编辑:

音频中断监听回调:

void interruptionListenerCallback (void *inUserData, UInt32 interruptionState)
{
    if (interruptionState == kAudioSessionBeginInterruption) 
    {
        [self.audioRecorder pause];
    } 
    else if (interruptionState == kAudioSessionEndInterruption) 
    {
        // if the interruption was removed, and the app had been recording, resume recording
        [self.audioRecorder resume];
    }
}

监听音频中断:

AudioSessionInitialize(NULL, NULL, interruptionListenerCallback, self);

这篇关于如何恢复记录后中断的iphone发生?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆