import UIKit
import Volumer
class ViewController: UIViewController {
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
//Use this if you want the volume buttons to still affect the device's playback volume
//The default is `true`
Volume.keepIntact = false
//Use your own MPVolumeView if you want
//Obs. This method needs to be executed if you have called `Volume.reset()`
Volume.use(self.volumeView)
//Register a volume up block
Volume.when(.Up) {
print("UP!")
}
//Register a volume down block
Volume.Down.when {
print("Down")
}
}
override func viewDidDisappear(animated: Bool) {
//Be sure to call this when you're done
Volume.reset()
super.viewDidDisappear(animated)
}
}
要运行示例项目,先克隆仓库,然后从 Example 目录中首先运行 pod install
iOS 8+
MediaPlayer
不使用 AVFoundation \o/
Volumer 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile
pod "Volumer"
Bell App Lab,[email protected]
Volumer 在 MIT 许可证下提供。有关更多信息,请参阅 LICENSE 文件。