Swift: Setting AVAudioSession Output Volume

后端 未结 2 1090
遥遥无期
遥遥无期 2021-01-15 17:25

Is there a way to set the AVAudioSession outputVolume?

    self.audioSession = AVAudioSession.sharedInstance()
    self.audioSession.setActive(true, error: n         


        
2条回答
  •  说谎
    说谎 (楼主)
    2021-01-15 18:15

    I was able to change the main volume using the following on iOS 8

    #import 
    
    [[MPMusicPlayerController applicationMusicPlayer] setVolume:0.0];
    [[MPMusicPlayerController iPodMusicPlayer] setVolume:0.0];
    

    for info, the code is called thru a Cordova pluggin. This effects the main volume (the device volume popup show the new volume when code is called)

提交回复
热议问题