views:

637

answers:

1

i know if we record video in iphone 3gs the video will be stored in temporary directory.so how do i get the path and play the video using mpmovieplayer?

+1  A: 
- (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);


    }

Then open Console to view the results :-) hope this helps

mrburns05