6

所以我试图让我的应用程序流式传输位于 Amazon S3 上的视频。到目前为止,我可以使用 Apple 的 MediaPlayer 教程做到这一点没问题:https ://developer.apple.com/library/ios/#samplecode/MoviePlayer_iPhone/Introduction/Intro.html

但是,我在我的应用程序中使用了 RestKit,因此也使用了 AFNetworking。我看到 AFNetworking 正在使用缓存,所以我想知道是否可以对视频做同样的事情?我不知道如何使用 AFNetworking 流式传输视频。所以这将是一个好的开始。我可以使用 AFNetworking 下载电影...但是我可以使用它进行流式传输还是只使用#import 提供的流式传输系统

NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"https://s3.amazonaws.com/leclerc/videos/sop/IMG_0141.MOV"]];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *path = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"IMG_0141.MOV"];
operation.outputStream = [NSOutputStream outputStreamToFileAtPath:path append:NO];

[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
    NSLog(@"Successfully downloaded file to %@", path);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    NSLog(@"Error: %@", error);
}];

[operation start];

例如,如果我在 Vevo 上观看音乐片段,然后在 5 分钟后重新观看,我是否必须在 iPad 上重新下载?!这对我来说是全新的,很抱歉我的无知!

4

0 回答 0