Swift 2017-03-17 20:32
Swift app声音管理库 Chirp
回复:0 查看:4754 感兴趣:17 赞:0
Swift app声音管理库 Chirp,可以通过简便的方式加载、播放、移除声音。
示例代码
prepareSound
用于将声音预加载到内存中。 这会将声音的拥有数量增加1。在调用playSound
之前必须调用此方法。
/* MyViewController.swift */ override func viewDidLoad() { super.viewDidLoad() // Load sounds into memory Chirp.sharedManager.prepareSound("boop") // default extension is .wav Chirp.sharedManager.prepareSound("ding.mp3") // so other extensions you must name explicitly }
通过playSound
播放预加载的声音。
func submitButtonTouched(button: UIButton) { // Since the sound is already loaded into memory, this will play immediately Chirp.sharedManager.playSound("boop") // example function that might get called when you touch a button submitForm() }
通过removeSound
从内存中移除声音。
deinit { // Cleanup is really simple! Chirp.sharedManager.removeSound("boop") Chirp.sharedManager.removeSound("ding.mp3") Chirp.sharedManager.removeSound("oops.mp3") // If you never loaded the sounds, e.g. viewDidLoad wasn't called, or submission never failed or succeeded, // that's ok, because these will function as no-ops }
相关开源代码
EFIconFont: 一个用 Swift 实现的 IconFont 封装
Swift Zip文件压缩与解压框架
EFResume - 一个普通的 Swift 简历模板
Swift 优雅的定时器及执行工具库 Each
Swift 解析、格式化及验证国际电话号码工具库 PhoneNumberKit
Swift 版 FlatBuffers(跨平台序列化库)FlatBuffersSwift
Swift 编写的 Github API 客户端 Github.swift
Swift OAuth授权库 SwiftyOAuth
Swift 音频处理库 TempiFFT
iOS通知中心封装库SwiftNotificationCenter