iOS - 从Parse下载视频数据

时间:2016-04-17 16:05:46

标签: objective-c parse-platform avfoundation nsdata

我正在尝试下载一个tfss文件(?)的PFFile。它作为文本文件打开。这是我用于检索数据的代码:

-(void) queryVideoWithDictionary:(NSDictionary *)dictionary {
    PFQuery *videoQuery = [PFQuery queryWithClassName:@"EventVideos"];
    [videoQuery whereKey:@"objectId" equalTo:[dictionary objectForKey:@"videoId"]];
    [videoQuery findObjectsInBackgroundWithBlock:^(NSArray *results, NSError *error) {
        if (!error) {
            PFFile *videoFile = [results[0] objectForKey:@"video"];
            [videoFile getDataInBackgroundWithBlock:^(NSData *data, NSError *error) {
                dispatch_async(dispatch_get_main_queue(), ^{
                    NSString *dataString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
                  //  NSURL *movieURL = [NSURL fileURLWithPath:dataString];

                    NSMutableDictionary *videoDictionary = [NSMutableDictionary dictionaryWithObject:data forKey:[dictionary objectForKey:@"videoId"]];
                    [self.videoArray addObject:videoDictionary];

                    NSLog(@"video array count: %ld", self.videoArray.count);

                    NSLog(@"dataString: %@", dataString);
                //    NSLog(@"movieURL: %@", movieURL);
                    [self.player setItemByStringPath:dataString];
                    [self.player play];
                });          
            }];
        } else {
            NSLog(@"error");
        }  
    }];
}

dataString被记录时,它返回null,所以我不知道如何获取数据并将其作为视频播放。顺便提一下,它保存为QuickTimeMovie。 我使用SCRecorder播放和录制视频。

编辑:data绝对不是零,我仍然不知道如何解决这个问题。

0 个答案:

没有答案