Floyd Resler
Floyd Resler

Reputation: 1786

iOS 8 Swift Audio Playback Execute Method On Completion

I am playing an audio file in Swift for iOS 8. I need to be able to know when the sound is finished. How can I have a method executed when the sound is finished?

Upvotes: 3

Views: 1652

Answers (1)

matt
matt

Reputation: 535491

It depends on how you're playing it. Look for a delegate method, a notification, or an observable property whose state change can trigger a KVO notification.

For example, if you're using an AVAudioPlayer, its delegate gets notified by a delegate method, which you can find out about here: https://developer.apple.com/library/ios/documentation/avfoundation/reference/AVAudioPlayerDelegateProtocolReference/index.html#//apple_ref/doc/uid/TP40008068

Upvotes: 3

Related Questions