使用AVAudioPlayer快速转发歌曲 [英] fast forwarding a song using AVAudioPlayer

查看:86
本文介绍了使用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.

推荐答案

使用 currentTime 持续时间属性。

ie跳过

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;

类似于倒退,只比较 currentTime 对于 0 ,而不是持续时间

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

这篇关于使用AVAudioPlayer快速转发歌曲的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆