完成时iOS 8 Swift音频播放执行方法 [英] iOS 8 Swift Audio Playback Execute Method On Completion

查看:88
本文介绍了完成时iOS 8 Swift音频播放执行方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Swift for iOS 8播放音频文件。我需要能够知道声音何时结束。如何在声音结束时执行方法?

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?

推荐答案

这取决于你如何演奏它。查找委托方法,通知或可观察属性,其状态更改可以触发KVO通知。

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.

例如,如果您正在使用AVAudioPlayer,则其 delegate 通过委托方法获得通知,您可以在此处找到: https://developer.apple.com/library/ios/documentation/avfoundation/reference/AVAudioPlayerDelegateProtocolReference/index.html #// apple_ref / doc / uid / TP40008068

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

这篇关于完成时iOS 8 Swift音频播放执行方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆