我正在尝试在这样的数组中初始化AVPlayerItem:
func parsePlaylist(json: JSON) {
var i : Int = 0
while i < json.count {
let itemId = json[i]["itemid"].intValue
let position = json[i]["position"].intValue
let author = json[i]["author"].stringValue
let title = json[i]["title"].stringValue
let url = json[i]["url"].stringValue
let playerItem = AVPlayerItem(url : json[i]["url"].url!)
//ERROR - Task <89776295-F9F3-4BBC-8908-5F0201A4CDBB>.<2> finished with error - code: -999
playlistItem.append(PlaylistItem(myItemId: itemId, myPosition: position, myAuthor: author, myTitle: title, myUrl: url, myPlayerItem: playerItem))
i += 1
}
}
执行此操作时,控制台显示json.count-乘以上述错误。
稍后尝试初始化我的播放器时:
var player : AVPlayer?
player = AVPlayer(playerItem: playlistItem[itemCounter].playerItem)
一切正常。
如何摆脱错误? 谢谢!