Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fast forwarding a song using AVAudioPlayer

I am creating an audio player application, i need to enable the user to fast forward and backward a song by holding a button(seperately for each). I've done for playing, stopping, skip to next and previous song. But i got stuck with this section. I dont know the method to implement this. pls help.

like image 553
Nithin Avatar asked Dec 17 '09 11:12

Nithin


1 Answers

Use the currentTime and duration properties.

i.e. to skip forward

NSTimeInterval time = avPlayer.currentTime;
time += 5.0; // forward 5 secs
if (time > avPLayer.duration)
{
    // stop, track skip or whatever you want
}
else
    avPLayer.currentTime = time;

Similar for going backwards, only compare currentTime against 0, instead of duration

like image 64
cidered Avatar answered Sep 19 '22 20:09

cidered