Leo
Leo

Reputation: 135

Move audio player 5 second fast-rewind & fast-forward

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

Answers (2)

iAhmed
iAhmed

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

Pratik
Pratik

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

Related Questions