VolumeButtons is simple way to handling clicks on hardware volume buttons on iPhone or iPad.
self.volumeButtonHandler = VolumeButtonHandler(containerView: view)
volumeButtonHandler.buttonClosure = { button in
// ...
}
volumeButtonHandler.start()
VolumeButtonHandler class keeps track of volume changes in an audio session. When you increase or decrease the volume level, the value will be reset to the initial one, thus pressing the buttons is determined without changing the volume of the media player. You need to pass in init
some view of your View Controller for placing hidden instance MPVolumeView
used for controlling volume level.
iOS 11 and newer.
VolumeButtons is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'VolumeButtons'
This project based on Objective-C code JPSVolumeButtonHandler