Skip to content

Instantly share code, notes, and snippets.

@KiranPanesar
Last active August 29, 2015 14:24
Show Gist options
  • Save KiranPanesar/53c2681e340cea31752a to your computer and use it in GitHub Desktop.
Save KiranPanesar/53c2681e340cea31752a to your computer and use it in GitHub Desktop.
NSError *categoryError;
NSError *activationError;
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
BOOL successfulCategory = [audioSession setCategory:AVAudioSessionCategorySoloAmbient error:&categoryError];
BOOL successfulActivation = [audioSession setActive:YES error:&activationError];
NSLog(@"Category: Error: %@. Success: %@", categoryError, [NSNumber numberWithBool:successfulCategory]);
NSLog(@"Category: Error: %@. Success: %@", activationError, [NSNumber numberWithBool:successfulActivation]);
AVPlayerItem *item = [[AVPlayerItem alloc] initWithURL:[[NSBundle mainBundle] URLForResource:@"trax"
withExtension:@"mp3"]];
player = [[AVPlayer alloc] init];
[player replaceCurrentItemWithPlayerItem:item];
[player play];
2015-07-13 16:02:28.912 AudioStreamingApp[5938:1005780] Category: Error: (null). Success: 1
2015-07-13 16:02:28.913 AudioStreamingApp[5938:1005780] Category: Error: (null). Success: 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment