【发布时间】:2013-07-16 17:05:18
【问题描述】:
我一直在看线程:语音检测 (http://mobileorchard.com/tutorial-detecting-when-a-user-blows-into-the-mic/)。
我希望通过以下变体实现类似的东西。
该示例中的 levelTimer 每 0.03 秒连续触发一次。我基本上需要围绕这个包装另一个计时器,以便语音检查过程只运行(比如说)10 秒。
我发现有类似的东西:
outerTimer = [NSTimer scheduledTimerWithTimeInterval:10.0
target:self
selector:@selector(outerTimerFinished:)
userInfo:nil
repeats:NO];
levelTimer = [NSTimer scheduledTimerWithTimeInterval:0.03
target:self
selector:@selector(listenForSounds:)
userInfo:nil
repeats:YES];
…outerTimerFinished 方法调用 [levelTimer invalidate] 不起作用 - 可能是由于线程阻塞?
那么有人可以帮我确定 levelTimer 的工作方式,但仅限于特定的时间吗?
谢谢。
【问题讨论】:
-
我已经发布了另一种方法,但我测试了你的方法,它对我有用。你在 ListeningForSounds: 里面做什么?
标签: ios nstimer voice-recording