0

I'm trying to put retrieved videos from Parse in UIimage and i need help of that. i retrieved videos as a PFFile . here is my code

 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
Wain
  • 118,658
  • 15
  • 128
  • 151

1 Answers1

0

The issue is that you can't put video data into a UIImage.

You need to get a UIImage as a thumbnail for the video, which has already been answered here.

From there, playing a video from a PFFile can be accomplished with the following steps

// 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()
Russell
  • 3,099
  • 2
  • 14
  • 18