0

我正在使用以下代码获取系统音量,但是如何在更改 UISlider 值时设置系统音量?

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

0 回答 0