我试图在UIimage中放置来自Parse的检索视频,我需要帮助。 我将视频检索为PFFile。 这是我的代码
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell :mineCell = tableView.dequeueReusableCellWithIdentifier("mineCell")as! mineCell
cell.usernameLabel.text = creator[indexPath.row]
videoFile[indexPath.row].getDataInBackgroundWithBlock { (videoData :NSData?, error:NSError?) -> Void in
if videoData != nil{
let video = UIImage(data: videoData!)
cell.videoView.image = video
println("it should the video load in the UImage ")
}
else {
println(error)
}
}
return cell
答案 0 :(得分:0)
问题在于您无法将视频数据放入UIImage中。
您需要将UIImage作为视频的缩略图which has already been answered here。
从那里,可以通过以下步骤播放来自PFFile的视频
// Load yourObject which has the video (PFFile)
var fileURL = NSURL(string: yourObject.video.url!)
var moviePlayer = MPMoviePlayerViewController(contentURL: fileURL)
self.presentMoviePlayerViewControllerAnimated(moviePlayer)
moviePlayer.moviePlayer.play()