iOS - 无法从Parse后端流式传输视频

Jos*_*osh 6 video streaming ios pffile parse-server

最近我使用mongoLab在heroku上创建了我自己的解析服务器来存储我的数据.

我的问题是我将视频保存为解析PFFile,但是在保存后我似乎无法流式传输.

这是我的确切步骤.

首先,我保存返回的视频 UIImagePicker

//Get the video URL
let videoURL = info[UIImagePickerControllerMediaURL] as? NSURL

//Create PFFile with NSData from URL
let data = NSData(contentsOfURL: videoURL!)
videoFile = PFFile(data: data!, contentType: "video/mp4")

//Save PFFile first, then save the PFUser
PFUser.currentUser()?.setObject(videoFile!, forKey: "profileVideo")
            videoFile?.saveInBackgroundWithBlock({ (succeeded, error) -> Void in
                print("saved video")
                PFUser.currentUser()?.saveInBackgroundWithBlock({ (succeeded, error) -> Void in
                    if succeeded && error == nil {
                        print("user saved")

                        //Hide progress bar 
                        UIView.animateWithDuration(0.5, animations: { () -> Void in                   
                            self.progressBar.alpha = 0
                            }, completion: { (bool) -> Void in
                                self.progressBar.removeFromSuperview()
                        })

                    }else{

                        //Show error if the save failed
                        let message = error!.localizedDescription
                        let alert = UIAlertController(title: "Uploading profile picture error!", message: message, preferredStyle: UIAlertControllerStyle.Alert)
                        let dismiss = UIAlertAction(title: "OK", style: UIAlertActionStyle.Cancel, handler: nil)
                        alert.addAction(dismiss)
                        self.presentViewController(alert, animated: true, completion: nil)

                    }
                })
                }, progressBlock: { (progress) -> Void in
                    self.progressBar.setProgress(Float(progress)/100, animated: true)
            })
Run Code Online (Sandbox Code Playgroud)

这一切都运作良好.问题在于我检索PFFile并尝试流式传输视频.这是我的代码:

//Get URL from my current user
self.videoFile = PFUser.currentUser()?.objectForKey("profileVideo") as? PFFile
                        self.profileVideoURL = NSURL(string: (self.videoFile?.url)!)

//Create AVPlayerController
let playerController = AVPlayerViewController()

//Set AVPlayer URL to where the file is stored on the sever
let avPlayer = AVPlayer(URL: self.profileVideoURL)
playerController.player = avPlayer

//Present the playerController
self.presentViewController(playerController, animated: true, completion: { () -> Void in
 playerController.player?.play()
})
Run Code Online (Sandbox Code Playgroud)

当我提出playerController这件事时最终会发生什么:

在此输入图像描述

当我尝试流式传输视频时,为什么会发生这种情况?

任何帮助是极大的赞赏!

UPDATE

我最近尝试使用以下代码行播放从其他数据库保存的视频: let videoURL = NSURL(string: "https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4")

这证实了我保存的格式PFFile是导致错误的格式.

必须是这一行导致错误,因为"video/mp4"可能不是正确的格式:videoFile = PFFile(data: data!, contentType: "video/mp4")

更新2

我已经使用了位于mongoLab上的.mp4文件的直接链接,发现我可以在谷歌浏览器中播放它,但不能在safari或我的iPhone上播放.

更新3

我发现这是解析api本身的一个问题,并且与代码无关,因为我的代码在使用原始解析后端(正在关闭的那个)而不是我的自定义解析服务器时工作得很好.我目前没有解决方案,但它应该随着时间的推移得到修复.

Sta*_*av1 -1

我有一个带有解析服务器的本地 mongodb,需要它才能工作:

解析服务器将视频从 PFFile.url 流式传输到 IOS

不知道非本地数据库是否相同。