Reputation: 135
I know this is a duplicate question but I didn't find out the exact answer. I am working with AVAudioPlayer. Now I have two buttons forward & rewind. When the user will tap the forward button the audio will move 5 second forward & when the user will tap the rewind button the audio will move 5 second rewind. How can i do this exactly? Thanks in advance for any help.
Upvotes: 0
Views: 1091
Reputation: 6704
- (IBAction)btnForwardClicked:(id)sender
{
NSTimeInterval *time = [player currentTime];
time+=SKIP_TIME;
//for reverse time-=SKIP_TIME
//SKIP_TIME is time which is jumped i-e 5 seconds
[player setCurrentTime:time];
}
Upvotes: 0
Reputation: 2399
Put below methods for forward and rewind player time
- (IBAction)btnForwardClicked:(id)sender
{
int currentTime = [player currentTime];
[player setCurrentTime:currentTime+5];
}
- (IBAction)btnBackwardClicked:(id)sender
{
int currentTime = [player currentTime];
[player setCurrentTime:currentTime-5];
}
here player is avaudio player's object
AVAudioPlayer *player;
Upvotes: 3