问题
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