How to set system volume as per UIslider value ? IOS Swift 3.0

2.1k Views Asked by At

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
    }
0

There are 0 best solutions below