移动音频播放器5秒快退&快进

时间:2013-08-02 06:50:41

标签: iphone ios avaudioplayer

我知道这是一个重复的问题,但我没有找到确切的答案。我正在使用AVAudioPlayer。现在我有两个按钮前进&倒带。当用户点击前进按钮时,音频将向前移动5秒钟。当用户点击倒带按钮时,音频将移动5秒后退。我怎么能这样做呢?提前感谢您的帮助。

2 个答案:

答案 0 :(得分:3)

将以下方法用于前进和后退播放器时间

 - (IBAction)btnForwardClicked:(id)sender
 {
      int currentTime = [player currentTime];
      [player setCurrentTime:currentTime+5];
 }

 - (IBAction)btnBackwardClicked:(id)sender
 {
      int currentTime = [player currentTime];
      [player setCurrentTime:currentTime-5];
 }

这里播放器是avaudio播放器的对象

AVAudioPlayer *player;

答案 1 :(得分:0)

 - (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];    

}