i want to set Iphone Speaker default. My volume control swift code is below. It is works fine but when i tapped airplay button i see automatically select the second.(Iphone)
var wrapperView = UIView(frame: CGRectMake(10,40,(self.view.bounds.size.width)-20, 20))           
        wrapperView.backgroundColor=UIColor.purpleColor()         
        self.view.addSubview(wrapperView)       
        var volumeView = MPVolumeView(frame: wrapperView.bounds)
        volumeView.tintColor=UIColor.purpleColor()  
        wrapperView.addSubview(volumeView)

Don't know if you've solved this... Just set the default to be to the speaker (add any others you want as well, eg Bluetooth, headphones...)
    do {
        try AVAudioSession.sharedInstance().setCategory(
            AVAudioSessionCategoryPlayAndRecord,
            withOptions: [.DefaultToSpeaker])
        success = true
    } catch _ {
    }
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With