【发布时间】:2014-10-07 15:39:26
【问题描述】:
通过使用文件名录制多个sn-ps,我尝试在SpeakHere中录制多个单独的短语音sn-ps,我想连续播放它们,间隔固定的间隔每个 sn-p 开始之间的时间。我希望 sn-ps 系列永远循环播放,或者直到用户停止播放。
我的问题是如何更改 SpeakHere 来做到这一点?
(我说“attempted”是因为我还不能在我的 Mac Mini iPhone 模拟器上运行 SpeakHere。That is the subject of another question 并且因为 another question on the subject of multiple files 也没有得到答复。 )
在SpeakHereController.mm 中是以下用于播放录制文件的方法定义。注意最后的else 子句调用player->StartQueue(false)
- (IBAction)play:(id)sender
{
if (player->IsRunning())
{ [snip]
}
else
{
OSStatus result = player->StartQueue(false);
if (result == noErr)
[[NSNotificationCenter defaultCenter] postNotificationName:@"playbackQueueResumed" object:self];
}
}
以下是SpeakHereAQPlayer.mm的摘录
OSStatus AQPlayer::StartQueue(BOOL inResume)
{
// if we have a file but no queue, create one now
if ((mQueue == NULL) && (mFilePath != NULL)) CreateQueueForFile(mFilePath);
mIsDone = false;
// if we are not resuming, we also should restart the file read index
if (!inResume) {
mCurrentPacket = 0;
// prime the queue with some data before starting
for (int i = 0; i < kNumberBuffers; ++i) {
AQBufferCallback (this, mQueue, mBuffers[i]);
}
}
return AudioQueueStart(mQueue, NULL);
}
那么,play和AQPlayer::StartQueue方法可以播放多个文件吗,如何强制执行间隔,如何重复循环?
我对方法'record`的代码改编如下,所以你可以看到多个文件是如何创建的。
- (IBAction)record:(id)sender
{
if (recorder->IsRunning()) // If we are currently recording, stop and save the file.
{
[self stopRecord];
}
else // If we're not recording, start.
{
self.counter = self.counter + 1 ; //Added *****
btn_play.enabled = NO;
// Set the button's state to "stop"
btn_record.title = @"Stop";
// Start the recorder
NSString *filename = [[NSString alloc] initWithFormat:@"recordedFile%d.caf",self.counter];
// recorder->StartRecord(CFSTR("recordedFile.caf"));
recorder->StartRecord((CFStringRef)filename);
[self setFileDescriptionForFormat:recorder->DataFormat() withName:@"Recorded File"];
// Hook the level meter up to the Audio Queue for the recorder
[lvlMeter_in setAq: recorder->Queue()];
}
}
【问题讨论】:
标签: ios voice-recording