How do I fastforward using AVAudioplayer while hearing the music?

ぐ巨炮叔叔 提交于 2019-12-02 19:08:04

问题


I got it to fast forward but I would like to hear the music when its fast forwarding. How would I be able to do this? Here is the code I have:

if node.name == "left" {

            var time = musicPlayer.currentTime
            time += 1.0
            musicPlayer.enableRate = true
            musicPlayer.rate = 2.0


            if time > musicPlayer.duration {

            } else {
                musicPlayer.currentTime = time
     }
}

回答1:


Have a look at the rate property on AVAudioPlayer

This property’s default value of 1.0 provides normal playback rate. The available range is from 0.5 for half-speed playback through 2.0 for double-speed playback.

To set an audio player’s playback rate, you must first enable rate adjustment as described in the enableRate property description.

You could change the rate for a certain amount of time when a button is pressed to simulate fast-forwarding



来源:https://stackoverflow.com/questions/36587401/how-do-i-fastforward-using-avaudioplayer-while-hearing-the-music

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!