玩完后如何运行第三种方法? 在其他流中播放音频
我有一些方法
- (void)play {
[self runTask:^{
[self someMethod];
} withCompletion:^{
[self secondMethod];
}]
;}
- (void)someMethod {
NSLog(@"method 1");
[[SoundManager sharedManager] playSound:@"" complete:^{
[self thirdMethod];
}];
}
- (void)secondMethod {
NSLog(@"method 2");
}
- (void)thirdMethod {
NSLog(@"method 3");
}
- (void)runTask:(void (^)())task withCompletion:(void (^)())completion {
if (task) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
if (task) {
task();
}
if (completion) {
completion();
}
});
}
}
也许你可以告诉我如何获得音频结束然后运行一些方法? 我使用AudioPlayerDelegate方法
- (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag {