2014-04-24 44 views
1

我正在使用AUGraph(從iPhonemixerEQgraphtest中取得的示例)實現一個播放器。我已經實現了下一首和前一首歌曲。但自從昨天以來,我一直在使用UISlider進行球員前鋒選擇。請問任何人都可以告訴我如何實現向前選項。爲了更好地理解,我已經包含了圖像。例如:如果我將滑塊滑動到10秒鐘,那麼它必須從第10秒播放樂曲。任何想法/建議可能是非常感激在iPhone混音器中使用AUGraph轉發歌曲EQGraph Test

enter image description here

+0

即使我面對一樣。如果你已經解決了它。你可以請分享你的解決方案 – Anand

+1

嗨,我已經完成了這一點。請在下面找到我的解決方案 – Tendulkar

回答

1

嗨經過長期的研究後,我已經找到了解決辦法

在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; 
}