【发布时间】:2016-04-14 03:07:14
【问题描述】:
我正在使用 AVAudioPlayer 播放音乐,需要帮助来倒带音乐。我使用rate = 2.0 让它快进,但现在我不确定如何使用 rate 属性或其他东西来倒带音乐。有人可以帮我解决这个问题。谢谢!
override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?) {
for touch in touches {
let location = touch.locationInNode(self)
let node = self.nodeAtPoint(location)
//this is for the left turntable
if node.name == "lefttt" {
//lets user rotate left turntable when there is one finger on turntable.
let dy = leftTurntable.position.y - location.y
let dx = leftTurntable.position.x - location.x
let angle2 = atan2(dy, dx)
leftTurntable.zRotation = angle2
let delta = (angle2 - previousAngle)
if delta > 0 {
//rewind code
print("rotateleft")
}
else {
print("rotateright")
musicPlayer.rate = 2
musicPlayer.play()
}
previousAngle = angle2
}
【问题讨论】:
标签: ios xcode swift swift2 avaudioplayer