I want to pause the song and continue from that point of duration in iphone using programmatic-ally. When I tried to pause the song and again I want to start to play the son
if(!player){
NSString* resourcePath = [[NSBundle mainBundle] resourcePath];
resourcePath = [resourcePath stringByAppendingString:@"/grabbag.m4a"];
NSLog(@"Path to play: %@", resourcePath);
NSError* err;
//Initialize our player pointing to the path to our resource
player = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:resourcePath] error:&err];
if( err ){
//bail!
NSLog(@"Failed with reason: %@", [err localizedDescription]);
}
else{
//set our delegate, flip the button and let the magic happen
player.delegate = self;
[self flipButton:YES];
[player play];
}
}
else{
//If the player exists here, then we're already playing.
NSLog(@"Resuming playback!");
[player play];
[self flipButton:YES];
}