ios - How to set a completionhandler for AVAudioEngine -


i using method play audio file;

-(void)playonmainthread:(id)param

{    [self playaudio];      avaudioengine *engine = [[avaudioengine alloc] init];     avaudioplayernode *node = [[avaudioplayernode alloc] init];     [engine attachnode:node];     avaudiounittimepitch *pitch = [[avaudiounittimepitch alloc] init];     pitch.pitch = 100;     pitch.rate = 2;     [engine attachnode:pitch];     avaudiomixernode *mixernode = engine.mainmixernode;     [engine connect:node to:pitch format:[mixernode outputformatforbus:0]];     [engine connect:pitch to:mixernode format:[mixernode outputformatforbus:0]];      avaudiofile *audiofile = [[avaudiofile alloc] initforreading:recorder.url error:&error];     if (error)         nslog(@"avaudioplayer error %@, %@", error, [error userinfo]);     if (audiofile != nil) {         [node schedulefile:audiofile attime:nil completionhandler:nil];         [engine startandreturnerror:nil];         [node play];     }     } 

but need set completionhandler, have tried;

-(void)stoptalking:(avaudionodecompletionhandler)handler //-(void)stoptalking {      isplaying = no;     [self unschedule:@selector(repeatspeackaction)];      [self schedule:@selector(startgamecall)];      [stand setdisplayframe:[[ccspriteframecache sharedspriteframecache] spriteframebyname:@"turn1.png"]];      if(video==true) {         cases=1;         [self addaudiotodict];     }  } 

i trying call using this;

[node schedulefile:audiofile attime:nil completionhandler:stoptalking]; 

without success, how can call completion handler?

you need use gcd block, instead of method, completionhandler parameter:

[node schedulefile:audiofile attime:nil completionhandler:^{      // "stoptalking" code goes here...  }]; 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -