我正在使用 AUGraph 实现一个播放器(以 iPhonemixerEQgraphtest 为例)。我已经实现了转到下一首和上一首歌曲。但从昨天开始,我一直在使用 UISlider 研究播放器的前进选项。谁能告诉我如何实现前向选项。为了更好地理解,我提供了图片。
例如:如果我将 slider 滑动到 10 秒,那么它必须从第 10 秒开始播放歌曲。任何想法/建议都将非常有用
最佳答案
嗨,经过长时间的研究,我找到了解决方案
在 AUGraphController.mm 中,我更改了这段代码
// the render notification is used to keep track of the frame number position in the source audio
static OSStatus renderNotification(void *inRefCon, AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList *ioData)
{
Simple_PlayerAppDelegate *appDel = (Simple_PlayerAppDelegate*)[[UIApplication sharedApplication] delegate];
SourceAudioBufferDataPtr userData = (SourceAudioBufferDataPtr)inRefCon;
//NSLog(@"userdata out is %lu",(userData->frameNum/44100));
appDel.secondsFromLocalSong = (userData->frameNum/44100);
if (*ioActionFlags & kAudioUnitRenderAction_PostRender)
{
//printf("post render notification frameNum %ld inNumberFrames %ld\n", userData->frameNum, inNumberFrames);
if(appDel.skipSecondsFromLocalSong>0)
{
userData->frameNum = (appDel.skipSecondsFromLocalSong*userData->maxNumFrames);
appDel.skipSecondsFromLocalSong = 0;
}
else
userData->frameNum += inNumberFrames;
if (userData->frameNum >= userData->maxNumFrames) {
//userData->frameNum = 0;
SilenceData(ioData);
}
}
return noErr;
}
关于ios - 在 iPhone Mixer EQGraph 测试中使用 AUGraph 转发歌曲,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23267480/