Set device volume on iPhone

前端 未结 2 1151
情歌与酒
情歌与酒 2021-02-10 18:35

I\'m writing an app that uses AVAudioPlayers to play sounds and I need the sounds to play at absolute MAX volume. Yes you can set the relative volume for an

相关标签:
2条回答
  • 2021-02-10 19:08

    I came across this:

     MPVolumeView *volumeView1 = [[MPVolumeView alloc] initWithFrame:CGRectMake(4, 316, sk.size.width, sk.size.height)]; 
    [volumeView1 sizeToFit]; 
    [self.view addSubview:volumeView1]; 
    [volumeView1 release]; 
    

    I'm not entirely sure if it will work, but I believe it should. It seems you might have to modify the height and width

    0 讨论(0)
  • 2021-02-10 19:26

    The comment from the anonymous for this site:

    float volume;
    [[MPMusicPlayerController applicationMusicPlayer] setVolume:volume];
    

    does actually work.

    0 讨论(0)
提交回复
热议问题