OSStatus错误2003334207 AVAudioPlayer

时间:2018-07-27 20:16:50

标签: ios swift avfoundation avaudioplayer

我正在尝试播放从iTunes API获得的音频URL。它们是m4a类型。我将URL保存为字符串,并将其发送到我的playSound函数。我看过其他出现此错误的帖子,但无法修复我的错误。

音频网址示例

https://audio-ssl.itunes.apple.com/apple-assets-us-std-000001/Music1/v4/fd/4b/f9/fd4bf91e-2a1d-a946-a2f5-2d828da0f8e5/mzaf_2707169172634594413.plus.aac.p.m4a

我收到错误消息“错误:操作无法完成。(OSStatus错误2003334207。)”

func playSound(soundUrl: String) {
    let sound = NSURL(fileURLWithPath: soundUrl)
    do {
        let audioPlayer = try AVAudioPlayer(contentsOf: sound as URL)
        audioPlayer.delegate = self as? AVAudioPlayerDelegate
        audioPlayer.prepareToPlay()
        audioPlayer.play()
    }catch let error {
        print("Error: \(error.localizedDescription)")
    }
}

0 个答案:

没有答案