I am getting a link from itunes search api, and trying to pass it into an AVPlayer, but I am getting an error. http://puu.sh/ldBCw/6bfff69c7d.png. Below is the code to get the link.
let task = NSURLSession.sharedSession().dataTaskWithURL(url) {(data, response, error) -> Void in
do {
if let dict: NSDictionary = try NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions.MutableContainers) as? NSDictionary
{
if let previewUrl = dict["results"]![0]["previewUrl"] {
print(previewUrl!)
player = AVPlayer(URL: previewUrl)
}
}
} catch let jsonError as NSError {
}
}
task.resume()
}