Skip to content

Instantly share code, notes, and snippets.

@chrisallick
Created July 17, 2013 00:07
Show Gist options
  • Save chrisallick/6016417 to your computer and use it in GitHub Desktop.
Save chrisallick/6016417 to your computer and use it in GitHub Desktop.
iOS AVAudioPlayer audio fade in.
soundPath = [[NSBundle mainBundle] pathForResource:@"soundtrack" ofType:@"m4a"];
soundtrack = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:soundPath] error:nil];
[soundtrack setVolume: 0.0];
[soundtrack prepareToPlay];
}
return self;
}
-(void)doVolumeFade {
if (soundtrack.volume < 0.1) {
soundtrack.volume = soundtrack.volume + 0.01;
[self performSelector:@selector(doVolumeFade) withObject:nil afterDelay:0.1];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment