我知道如果我们在 iphone 3gs 中录制视频,视频将存储在临时目录中。那么我如何获取路径并使用 mpmovieplayer 播放视频?
问问题
2430 次
2 回答
1
- (void)video:(NSString *)videoPath didFinishSavingWithError:(NSError *)error contextInfo:(NSString *)contextInfo{
NSLog(@"didFinishSavingWithError--videoPath in temp directory:%@",contextInfo);
NSString *file,*latestFile;
NSDate *latestDate = [NSDate distantPast];
NSDirectoryEnumerator *dirEnum = [[NSFileManager defaultManager] enumeratorAtPath:[[contextInfo stringByDeletingLastPathComponent]stringByDeletingLastPathComponent]];
// Enumerate all files in the ~/tmp directory
while (file = [dirEnum nextObject]) {
// Only check files with MOV extension.
if ([[file pathExtension] isEqualToString: @"MOV"]) {
NSLog(@"latestDate:%@",latestDate);
NSLog(@"file name:%@",file);
NSLog(@"NSFileSize:%@", [[dirEnum fileAttributes] valueForKey:@"NSFileSize"]);
NSLog(@"NSFileModificationDate:%@", [[dirEnum fileAttributes] valueForKey:@"NSFileModificationDate"]);
// Check if current jpg file is the latest one.
if ([(NSDate *)[[dirEnum fileAttributes] valueForKey:@"NSFileModificationDate"] compare:latestDate] == NSOrderedDescending){
latestDate = [[dirEnum fileAttributes] valueForKey:@"NSFileModificationDate"];
latestFile = file;
NSLog(@"***latestFile changed:%@",latestFile);
}
}
}
// The Video path.
latestFile = [NSTemporaryDirectory() stringByAppendingPathComponent:latestFile];
NSLog(@"This Is The Recent Video:%@",latestFile);
}
然后打开控制台查看结果:-) 希望这会有所帮助
于 2009-10-30T01:58:57.143 回答
1
- (void)video:(NSString *)videoPath didFinishSavingWithError:(NSError *)error contextInfo:(NSString *)contextInfo{
NSString *originalPathOfVideo=videoPath;//this will give the path of ur storing video,use this as a url and assign this url to ur mpmovieplayer
}
于 2011-11-03T08:57:34.240 回答