gpt4 book ai didi

ios - 如何在听到音乐时使用 AVAudioplayer 快进?

转载 作者:行者123 更新时间:2023-11-29 01:04:20 27 4
gpt4 key购买 nike

我让它快进了,但我想在快进时听到音乐。我怎样才能做到这一点?这是我的代码:

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
}
}

最佳答案

看看 rate 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.

您可以在按下按钮时更改一定时间的速率以模拟快进

关于ios - 如何在听到音乐时使用 AVAudioplayer 快进?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36587401/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com