I\'m trying to ascertain whether it\'s possible to toggle AirPlay support using the AVAudioPlayer
class.
From what I have read:
A
In response to my own question. It looks like the simple way is to add the custom volume controller is mentioned here: [ ref ], and it will work perfectly with the MPAudioPlayer
. Its just a matter of positioning it.
Its pretty easy with Interface Builder so you can easily utilize Auto Layout. Place anywhere you want an UIView object onto your main view then create a subclass of MPVolumeView and use this custom class for your UIView object
and the class VolumeView subclass of MPVolumeView
import UIKit
import MediaPlayer
class VolumeView: MPVolumeView {
convenience init() {
self.init()
}
override func drawRect(rect: CGRect) {
self.showsVolumeSlider = false
self.layer.cornerRadius = 10.0
self.clipsToBounds = true
}
}