1. 简短的提示音,如果是用生成系统声音的方法,在用音量控制键调节音量时,有时会出现只能更改音量,而系统声音只受铃声音量大小影响,所以会导致音量无法调节情况:
NSString*path = [[NSBundlemainBundle] pathForResource:@"countdown"ofType:@"wav"];
AudioServicesCreateSystemSoundID((__bridge CFURLRef)[NSURL fileURLWithPath:path], &soundID);
AudioServicesPlaySystemSound(soundID);
修改为:
NSString *path = [[NSBundlemainBundle] pathForResource:@"countdown"ofType:@"wav"];
_player= [[AVAudioPlayeralloc] initWithContentsOfURL:[NSURLURLWithString:path]error:nil];
[_player setNumberOfLoops:0];
[_player prepareToPlay];
[_player play];```
网友评论