标签:oss status recording pre 自己 void play category tca
录音(播放)和暂停
-(void)start { self.soundTotalLength = 0.0f; if (!self.unitHaveStart) { NSError *error = nil; [self.audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error:&error]; [self.audioSession setActive:YES error:&error]; OSStatus status = AudioOutputUnitStart(_audioUnit); if (status == noErr) { self.unitHaveStart = YES; } } self.isStatusInRecordingSound = YES; } -(void)pause {
//以下的问题在设置了后台播放功能时体现 //不调用该函数将导致回调函数一直在执行,录音无法暂停 AudioOutputUnitStop(_audioUnit); self.unitHaveStart = NO; self.isStatusInRecordingSound = NO; //不设置该模式,退到后台后将无法正常播放视频,导致视频一直立刻暂停(优酷),一直暂停播放(相册自己保存的视频),正常播放(相册手机录制的视频) NSError *error = nil; [self.audioSession setCategory:AVAudioSessionCategoryPlayback error:&error]; [self.audioSession setActive:NO error:&error]; }
标签:oss status recording pre 自己 void play category tca
原文地址:https://www.cnblogs.com/yuxiaoyiyou/p/9370783.html