Is there a way to set the AVAudioSession outputVolume?
self.audioSession = AVAudioSession.sharedInstance()
self.audioSession.setActive(true, error: n
The outputVolume
property is read-only. This is due to Apple's conviction that a good user experience will be broken if apps unexpectedly modify sound volume beyond user control.
From the AVAudioSession docs:
The system wide output volume can be set directly only by the user; to provide volume control in your app, use the MPVolumeView class
So this is your only (easy) option...
MPVolumeView *myVolumeView =
[[MPVolumeView alloc] initWithFrame:frame];
[self.view addSubview: myVolumeView];
I was able to change the main volume using the following on iOS 8
#import <MediaPlayer/MediaPlayer.h>
[[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)