我想用AVAudioPlayer播放30秒的Spotify歌曲预览。的URL MP3文件看起来像这样:https://p.scdn.co/mp3-preview/4f5fa753f8e814c51c718bf34bbc594bf55ef5b2AVAudioPlayer不播放MP3音效
这里是我的代码来播放这首歌曲:
trackObj.previewURL = NSURL(fileURLWithPath:"https://p.scdn.co/mp3-preview/4f5fa753f8e814c51c718bf34bbc594bf55ef5b2")
// set up the audio player
if trackObj.previewURL != nil {
do {
try previewPlayer = AVAudioPlayer(contentsOfURL: trackObj.previewURL)
previewPlayer.prepareToPlay()
previewPlayer.play()
} catch _ {}
}
这并不做任何事情。这首歌根本没有开始播放。