没有在AVAudioRecorder中工作的AudioServicesPlaySystemSound(ksystemsoundid_ate)。

时间:2022-04-24 17:37:45

I want to record audio with AVAudioRecorder.

我想用AVAudioRecorder录音。

Here is the code:

这是代码:

-(void)recordButtonTouchDown {

    _textLabel.backgroundColor = [UIColor clearColor];
    _timer = [NSTimer scheduledTimerWithTimeInterval:0.05
                                              target:self
                                            selector:@selector(setVoiceImage)
                                            userInfo:nil
                                             repeats:YES];

}

-(void)setVoiceImage {

    currentCount += 0.05f;

    if (currentCount==50) {
       AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
    }
}

AudioServicesPlaySystemSound(kSystemSoundID_Vibrate) not working, why?

AudioServicesPlaySystemSound(kSystemSoundID_Vibrate)不工作,为什么?

1 个解决方案

#1


0  

It's possibly a floating point rounding error in the following statement, as testing if floating point numbers are equal really requires an Epsilon value:

在下面的语句中,它可能是一个浮点数舍入误差,因为如果浮点数相等,那么就需要一个值:

if (currentCount==50) {

Try this instead:

试试这个:

if (currentCount >= 50.0f) {

To confirm: add a breakpoint inside the if statement.

确认:在if语句中添加断点。

#1


0  

It's possibly a floating point rounding error in the following statement, as testing if floating point numbers are equal really requires an Epsilon value:

在下面的语句中,它可能是一个浮点数舍入误差,因为如果浮点数相等,那么就需要一个值:

if (currentCount==50) {

Try this instead:

试试这个:

if (currentCount >= 50.0f) {

To confirm: add a breakpoint inside the if statement.

确认:在if语句中添加断点。