Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IOS Query current audio volume

I am programming an app to allow for locally stored mp3 file playback as well as streaming from a server.

I use

  AVAudioPlayer *player;
  AVPlayer *player2;

depending on the type of playback. How do I query what the device volume level is initially so that I can set my volume.slider to its initial value?

like image 763
justdan0227 Avatar asked Mar 11 '26 04:03

justdan0227


1 Answers

First, import:

#import <AVFoundation/AVAudioSession.h>

Then get The system wide output volume set by the user using:

float volume = [[AVAudioSession sharedInstance] outputVolume];
like image 132
Hong Duan Avatar answered Mar 13 '26 20:03

Hong Duan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!