为什么调用 audioplayer.play(atTime: delay) 不管 delay 的值如何都没有声音
Why calling audioplayer.play(atTime: delay) makes no sound regardless of the value of delay
预计:
调用audioplayer.play(atTime: 1)时,定时器重置为0,音频播放器在第1秒播放
现实:
我试过 delay = 0.000000001, 1, 100000000,但无论如何,都不会播放噪音。然而,代码显然被执行了(因为 "function was called" 出现在控制台中)
为什么会出现差异?
C = AVAudioPlayer() // assume other setups are done
C.play(atTime: 1)
print("function was called")
根据官方API参考(我翻译成swift3):
声明
func play(atTime time: TimeInterval) -> Bool
参数
时间:
开始播放的绝对音频输出设备时间。您提供给时间参数的值必须大于设备的当前时间。您可以使用如下代码延迟开始播放:
let playbackDelay = 3.0 // must be ≥ 0
myAudioPlayer.play(atTime: myAudioPlayer.deviceCurrentTime + playbackDelay)
预计:
调用audioplayer.play(atTime: 1)时,定时器重置为0,音频播放器在第1秒播放
现实:
我试过 delay = 0.000000001, 1, 100000000,但无论如何,都不会播放噪音。然而,代码显然被执行了(因为 "function was called" 出现在控制台中)
为什么会出现差异?
C = AVAudioPlayer() // assume other setups are done
C.play(atTime: 1)
print("function was called")
根据官方API参考(我翻译成swift3):
声明
func play(atTime time: TimeInterval) -> Bool
参数
时间:
开始播放的绝对音频输出设备时间。您提供给时间参数的值必须大于设备的当前时间。您可以使用如下代码延迟开始播放:
let playbackDelay = 3.0 // must be ≥ 0
myAudioPlayer.play(atTime: myAudioPlayer.deviceCurrentTime + playbackDelay)