I have this code:
-(void)createAndPlaySoundID: (NSString*)name
{
NSString *path = [NSString stringWithFormat: @"%@/%@", [[NSBundle mainBundle] resourcePath], name];
NSURL* filePath = [NSURL fileURLWithPath: path isDirectory: NO];
SystemSoundID soundID;
AudioServicesCreateSystemSoundID((__bridge CFURLRef)filePath, &soundID);
AudioServicesPlaySystemSound(soundID);
}
I call this like so:
[self createAndPlaySoundID: @"mySound.caf"];
This works great, however I have no control over the volume. I simply want the volume to be controlled by the user using the standard physical volume buttons on their iPad.
If I put this volume down to say 1, it plays, great, but then if I whack the device volume up to max its the same volume.
Any help would be appreciated, handling this, thanks.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…