0
我試圖在兩個對象發生碰撞時播放聲音,並且每次都出現此錯誤。我用我的iPhone 6測試下面的代碼:嘗試播放音頻時出現錯誤:998:未能設置聲音,err = -50
guard soundEffects[sound] == nil else
{
print("Sound effect \(sound) already exists")
return false
}
guard let soundURL = NSBundle.mainBundle().URLForResource(sound, withExtension:format, subdirectory:path) else
{
print("Error creating URL for resource \(sound)")
return false
}
print(soundURL)
var systemID : SystemSoundID = id
soundEffects[sound] = systemID
print(AudioServicesCreateSystemSoundID(soundURL, &systemID))
id += 1
,我嘗試播放它像這樣:
guard soundEffects[sound] != nil else
{
print("Sound effect '\(sound)' not found")
return false
}
print(soundEffects[sound]!)
AudioServicesPlaySystemSound(soundEffects[sound]!)
文件的格式爲WAV和我打印出來的代碼創建方法是0.我也似乎無法找到有關蘋果網站或網絡上任何其他地方的錯誤的任何文檔。難道我做錯了什麼?
更新:
顯然存儲在字典中的價值以後又加載它是什麼導致出現該錯誤。但事情是我需要有一個ID的字典。我應該如何存儲ID,爲什麼存儲它會導致錯誤?