Skip to content

Instantly share code, notes, and snippets.

@Koze
Last active July 13, 2021 18:00
Show Gist options
  • Save Koze/058f12cd85d6f029c647 to your computer and use it in GitHub Desktop.
Save Koze/058f12cd85d6f029c647 to your computer and use it in GitHub Desktop.
Private volume API with MPMusicPlayerController
// MPMusicPlayerController has private method setVolume: and setVolumePrivate:
// The following KVO works on iOS 8.3.
MPMusicPlayerController *playerController = [MPMusicPlayerController systemMusicPlayer];
[playerController setValue:@(0.1) forKey:@"volume"];
[playerController setValue:@(0.2) forKey:@"volumePrivate"];
@cyberdude
Copy link

Hi @Koze.

Thanks for sharing this! Do you happen to know if you can just lower the systemMusicPlayer but not the whole device volume? These two keys are affecting the whole system volume

Maybe there's a magic key hidden somewhere ;)

Cheerios,
capo

@Koze
Copy link
Author

Koze commented Jul 13, 2021

@cyberdude
I think that the volume of systemMusicPlayer is equivalent to device volume like Music app.
Therefore, there will be no API for control only the volume of the music.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment