我通过设置AVAudioPlayer
值来快速转发rate
。但是我无法弄清楚如何倒带。
我正在制作一个DJ应用,音乐的播放rate
在旋转转盘时发生变化,导致音乐快进和快退(同时仍然听到声音)。
这是我目前转盘旋转的方法。如何回放AVAudioPlayer
?
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 {
// Code to rewind music goes here....
print("rotateleft")
} else {
//This code works perfectly and fast forwards the music when spinning turntable to right
print("rotateright")
musicPlayer.rate = 2.0
musicPlayer.play()
}
previousAngle = angle2
}
答案 0 :(得分:0)
您可以通过将public class CustomerCollectionValidator: CompositeValidator<CustomerCollection>
{
public CustomerCollectionValidator()
{
RuleFor(x => x.ListOfCustomers)
.Must(ShouldHaveOneSurName)
.WithMessage("Should have one Surname in list");
RuleForEach(x => x.ListOfCustomers).SetValidator<CustomerValidator>();
}
public bool ShouldHaveOneSurName(List<Customer> lstCustomers)
{
if (lstCustomers== null)
{
return false;
}
return lstCustomers.Any(x => !String.IsNullOrWhiteSpace(x.SurName);
}
}
设置为小于其当前值的值来回放。
我认为这不会以某种听觉的方式回放。你不会神奇地听到音乐倒退或类似的东西。 AVAudioPlayer不这样做。但是,它会改变比赛位置,这样当你再次开始比赛(前锋)时,你将比你现在更早开始。
AVPlayer(与AVAudioPlayer相对)可以反向播放,但仅限于特定的AVPlayerItem允许的情况。