Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Attempt to play the new sound file.
- NSError *error = nil;
- player = [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error: &error];
- if (nil != error) {
- ZZLogInfo(@"AVAudioPlayer failed to create: %@.", error);
- }
- self.player = player;
- [self adjustVolume];
- [player setDelegate:self];
- [[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
- if ([player prepareToPlay]) {
- [player play];
- } else {
- [[UIApplication sharedApplication] endReceivingRemoteControlEvents];
- }
- - (void)adjustVolume
- {
- MPMusicPlayerController* appMusicPlayer = [MPMusicPlayerController applicationMusicPlayer];
- self.lastAbsoluteVolume = [appMusicPlayer volume];
- if (self.lastAbsoluteVolume < MinVolume) {
- [appMusicPlayer setVolume:MaxVolume];
- }
- }
Add Comment
Please, Sign In to add comment