AVAudioPlayer and AirPlay - possible?

后端 未结 2 876
一个人的身影
一个人的身影 2021-01-03 01:53

I\'m trying to ascertain whether it\'s possible to toggle AirPlay support using the AVAudioPlayer class.

From what I have read:

A

相关标签:
2条回答
  • 2021-01-03 02:33

    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.

    0 讨论(0)
  • 2021-01-03 02:39

    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
    
    }
    

    }

    0 讨论(0)
提交回复
热议问题