0

I am getting system volume using following code, But how to set system volume when change UISlider value ?

override func viewDidLoad() {
        super.viewDidLoad()        
        NotificationCenter.default.addObserver(self, selector:#selector(self.volumeChanged(note:)),name: NSNotification.Name(rawValue: "AVSystemController_SystemVolumeDidChangeNotification"), object:  player.currentItem)          
    }


func volumeChanged(note: NSNotification)  {
        let volume = AVAudioSession.sharedInstance().outputVolume
        print("System volume:",volume);
        volumeSlider.value = volume
    }
AtulParmar
  • 4,358
  • 1
  • 24
  • 45
  • "The system wide output volume can be set directly only by the user; to provide volume control in your app, use the `MPVolumeView` class." From the doc of `AVAudioSession.sharedInstance().outputVolume`. – Larme Mar 02 '17 at 16:11
  • AVAudioSession.sharedInstance().outputVolume in that "outputVolume" is read only property, And how to use MPVolumeView to change system volume, Please suggest. – AtulParmar Mar 02 '17 at 16:18

0 Answers0