0

I am completely new to Parse Platform. Im trying load video from parse server hosted on heroku using mongoLab to store data.

I have a video as PFFile in database and I can fetch it in my iOS app too as a PFFileObject. But I can't find any leads how to load / extract video data or url from PFFileObject.

To be more specific, I want to play this video in table view cell with AVPlayer / AVPlayerLayer.

            let file = self.pastWinnersData[0].value(forKey: "video") as AnyObject
            
            if let parseFile = file as? PFFileObject {
                let query = PFQuery(className: "Winner")
                
                query.getObjectInBackground(withId: parseFile ) { object, error in
                    if (error == nil && object != nil) {
                        let videoFile = object!["keyForVideoPFFile"] as! PFFileObject
                        self.videoURL = videoFile.url!
                    }
                    
                }

I tried above code but I don't understand

query.getObjectInBackground(withId: STRING_VALUE ) 

what id should I pass at

STRING_VALUE

I have gone through

https://stackoverflow.com/questions/35235340/ios-cant-stream-video-from-parse-backend

& https://stackoverflow.com/questions/37016487/cant-stream-video-pffile-from-parse-server?noredirect=1&lq=1

these are kind on same question but can't find solutions useful.

  • getObjectInBackground should return a PFFile and on that you should try calling `getDataInBackground` to get NSData for file – Shubhank Sep 09 '22 at 11:34
  • @Shubhank ok. and query.getObjectInBackground(withId: STRING_VALUE ) from where I can get this id ? – Rashmi Aher Sep 09 '22 at 11:47
  • https://parseplatform.org/Parse-SDK-iOS-OSX/api/Classes/PFFileObject.html simply call getDataInBackground on parseFile in your code – Shubhank Sep 09 '22 at 11:51

0 Answers0