开发者

how to play the audio after given period of time

开发者 https://www.devze.com 2022-12-15 06:00 出处:网络
i want to play the audio file after th开发者_运维知识库e given period of time set by user.You could use an NSTimer for this purpose like Andy Suggests but it may just over complicate things in this pa

i want to play the audio file after th开发者_运维知识库e given period of time set by user.



You could use an NSTimer for this purpose like Andy Suggests but it may just over complicate things in this particular situation. More simply, you could implement something like this:

- (void)playSound {
  [sound play];
}

- (void)someMethod {
  float delay = 2.0; // seconds
  [self performSelector:@selector(playSound) withObject:nil afterDelay:delay];
}


How about using the NSTimer class?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号