Is this the right way to check AVAudioPlayer's current playback time.
[audioPlayer play];
float seconds = audioPlayer.currentTime;
float seconds = CMTimeGetSeconds(duration);
How I can code after
[audioPlayer play];
that when currentTime is equal to 11 seconds then
[self performSelector:@selector(firstview) withObject:nil];
and after firstview when currentTime is equal to 23 seconds
[self performSelector:@selector(secondview) withObject:nil];
You could set up a
NSTimerto check the time periodically. You would need a method like:Then set up the NSTimer object to call this method every second (or whatever interval you like):
Check the NSTimer documentation for more details. You do need to stop (invalidate) the timer at the right time when you’re through with it:
https://developer.apple.com/documentation/foundation/nstimer
EDIT:
secondswill probably not be exactly 11 or 23; you’ll have to fiddle with the granularity.