ios - 在 iPhone Mixer EQGraph 测试中使用 AUGraph 转发歌曲

标签 ios objective-c

我正在使用 AUGraph 实现一个播放器(以 iPhonemixerEQgraphtest 为例)。我已经实现了转到下一首和上一首歌曲。但从昨天开始,我一直在使用 UISlider 研究播放器的前进选项。谁能告诉我如何实现前向选项。为了更好地理解,我提供了图片。

例如:如果我将 slider 滑动到 10 秒,那么它必须从第 10 秒开始播放歌曲。任何想法/建议都将非常有用

enter image description here

最佳答案

嗨,经过长时间的研究,我找到了解决方案

在 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/

相关文章:

ios - Swift:在自动格式化 UITextField 后动画化 UIButton

ios - 为什么 UITableViewCell 的 contentView 高度总是比 UITableViewCell 小一个点?

javascript - 单像素 CSS 错误?

ios - 如何在UIImageView中设置透明背景色

ios - IOS开发中protocol、extension、category有什么区别?以及如何恰本地使用它们?

ios - 为什么不能直接将 UIView 添加到 UITableViewCell 但 contentView

ios - 在 View Controller 中使用类别

objective-c - 初始化丢弃 Objective-C/cocoa 中指针目标类型错误的限定符

ios - UIButton 没有响应我对 collectionView 单元格的触摸?

objective-c - 当函数的类不继承自 NSObject 时,从 ObjC 调用一个 swift 实例函数