Shweta Simply
Shweta Simply

Reputation: 47

how to get path of temp recorded video file in iphone sdk and play?

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?

Upvotes: 0

Views: 2467

Answers (2)

sammy
sammy

Reputation: 19

- (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

}

Upvotes: 1

mrburns05
mrburns05

Reputation: 189

- (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

Upvotes: 1

Related Questions