objective-ciosvolumempvolumeview

App audio volume


I need the user to control the device's media volume. I've seen many solutions using volume view or AVAudioPlayer, but I want to use the device volume buttons to set the app volume, like many apps have.

Thanks!


Solution

  • To use this functionality you need to set the audio session to playback. This is done with something like this:

    AVAudioSession *session = [AVAudioSession sharedInstance];
    [session setCategory:AVAudioSessionCategoryPlayback error:nil];