- (无效)shouldPlayVideo { //您可以通过SDK下载视频数据,也可以使用Parse上存储的视频网址。
// Say you have a Class on Parse called MyClass, that has a column of type File named MyFile:
// assuming you've queried MyClass and have an object, we'll call it object
PFQuery *query = [PFQuery queryWithClassName:kPAPPhotoClassKey];
[query whereKey:@"Type" equalTo:@"Video"];
// [查询whereKey:kPAPActivityFromUserKey equalTo:[PFUser currentUser]];
[query orderByDescending:@"createdAt"];
NSArray *ary = [query findObjects];
NSLog(@"ary is %@",ary);
for (int i=0; i<1; i++) {
PFObject *obj = [ary objectAtIndex:i];
PFFile *theFile = obj[@"image"];
NSLog(@"%@",theFile.url);
// NSURL * url = [NSURL URLWithString:theFile.url];
// the .url property contains the URL for the file (video or otherwise)..
// If you want to download the data:
[theFile getDataInBackgroundWithBlock:^(NSData *data, NSError *error) {
// data contains the full file... this block will run when it is downloaded.
// use it inside this block.
NSString *yourstring = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSURL *url = [[NSURL alloc] initWithString:yourstring];
NSLog(@"url of video file is %@",url);
MPMoviePlayerViewController* theMovie =
[[MPMoviePlayerViewController alloc] initWithContentURL:url];
[theMovie.view setFrame:CGRectMake(20, 50, 280, 200)];
// [self presentMoviePlayerViewControllerAnimated:theMovie];
[self.scrollView addSubview:theMovie.view];
}];
} }