如何使用从保存为PFFile的parse下载的MPMoviePlayerController播放视频? 我用以下代码下载了视频文件:
var query = PFQuery(className:"Video")
query.whereKey("Nome", equalTo:"prova")
query.findObjectsInBackgroundWithBlock {
(objects: [AnyObject]?, error: NSError?) -> Void in
if error == nil {
// The find succeeded.
println("Successfully retrieved \(objects!.count) scores.")
if let objects = objects as? [PFObject] {
for object in objects {
var imageFile:PFFile =object.objectForKey("Video")
imageFile.getDataInBackgroundWithBlock {
(imageData: NSData?, error: NSError?) -> Void in
?????????????
}
}
} else {
println("Error: \(error!) \(error!.userInfo!)")
}
}
答案 0 :(得分:0)
您可以将该数据临时保存在文档目录中,并从
NSString *strLocation = [@"~/Documents/downloadedFile.mov" stringByExpandingTildeInPath];
// Use Your Downloaded Data
[data writeToFile:strLocation atomically:YES];
// Pass URL of that saved file in Player
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:strLocation]];
希望这会对你有所帮助。