我有一首歌曲存储在iCloudDrive中。我成功检索了这首歌,没有出现任何错误,但它不会播放。任何帮助将不胜感激,谢谢。
下面的代码:
let urls = "file:///private/var/mobile/Containers/Data/Application/98254AF0-9F67-4E86-BF26-368F46418E35/tmp/com.XYZ-Inbox/Alan.mp3"
fileURLed = URL(string: urls)
print(fileURLed!)
let url = fileURLed
if let url = url {
do {
let audioFile = try AVAudioFile(forReading: url)
timeShift.rate = adjustedBpm/bpm
playerNode.scheduleFile(audioFile, at: nil, completionHandler: nil)
} catch {
print("could not load audio file")
}
} else {
print("could not load audio file")
}
if playButton.titleLabel?.text == "Play Song" {
playerNode.play()
}else if playButton.titleLabel?.text == "Pause"{
playerNode.pause()
}
错误打印:无法加载音频文件