As the title suggests, I'm trying to figure out how to count the number of times an NSSound loops (or, more accurately, have a function run at the beginning and/or end of each loop). I've looked at all the documentation, but I can't find anything. Any help would be greatly appreciated.
UPDATE: I've tried using func sound(sound: NSSound, didFinishPlaying aBool: Bool), but it doesn't seem to trigger after a loop completes. The code:
func sound(sound: NSSound, didFinishPlaying aBool: Bool) {
pbNowPlaying.doubleValue = sound.currentTime
if aBool == true {
self.btnPlay.title = NSLocalizedString("titlePlay", comment: "Play")
self.btnPlay.state = NSOffState
self.pbNowPlaying.doubleValue = 0
self.btnPlay.needsDisplay = true
}
else {
Swift.print("Sound Looping")
}
self.needsDisplay = true
}
Have you tried the didFinishPlaying function? It is called every time the sound file finishes its clip.
What about creating a variable that will increase each time the function is called forth? Something easy that will keep track of a count? The count is what your looking for correct?