Skip to content

Instantly share code, notes, and snippets.

@jonahsiegle
Created August 2, 2012 00:34
Show Gist options
  • Save jonahsiegle/3231917 to your computer and use it in GitHub Desktop.
Save jonahsiegle/3231917 to your computer and use it in GitHub Desktop.
fixed
- (void)playPause:(id)sender {
player = [MPMusicPlayerController applicationMusicPlayer];
if ([songs count] > 0) {
if (isPlaying) {
NSLog(@"Playing music");
[player pause];
[sender setTitle:@"Pause" forState:UIControlStateNormal];
isPlaying = NO;
} else{
NSLog(@"Music paused.");
[player play];
[sender setTitle:@"Play" forState:UIControlStateNormal];
isPlaying = YES;
}
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Uh oh!" message:@"You forgot to select some music!" delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
[alert show];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment