IOS 声音控制

1. 改变声音音量使用:

MPVolumeView:controls every sound within the app;

[[MPMusicPlayerController applicationMusicPlayer] setVolume:volumeValue]: controls audio volume;


2. 播放声音:

NSURL *url = [NSURLURLWithString:@"/System/Library/Audio/UISounds/begin_video_record.caf"];

AVAudioPlayer *audio = [[AVAudioPlayeralloc] initWithContentsOfURL:url error:nil];

[audio play];


3. 播放系统声音(这种播放声音的音量无法改变)

    SystemSoundID myAlertSound;

    NSURL *url = [NSURL URLWithString:@"/System/Library/Audio/UISounds/begin_video_record.caf"];

    AudioServicesCreateSystemSoundID((__bridge CFURLRef)(url), &myAlertSound);    

    AudioServicesPlaySystemSound(myAlertSound);


你可能感兴趣的:(IOS)