Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 04-01-2010, 11:16 AM   #11 (permalink)
mrburns05
Registered Member
 
Join Date: Sep 2009
Posts: 23
mrburns05 is on a distinguished road
Default

Quote:
Originally Posted by mrburns05 View Post
The thumbnail gets created in your apps /temp folder within its appspace,
anytime you pick a video or record a video. so in theory all you gotta do is:

Each time you import or record a video, have your app search the temp dir for the latest file created with the "jpg" extension.

Im working on this myself, ill post code if i figure it out
Okay my bad= the jpg only gets created when you record a video with the app, & NOT when importing from library.

Apparently there's a way to do it with ffmeg library though so I'll look into this

and here is supposedly how you'd get it from a recording:

Code:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
*// e.g.
*NSString *tempFilePath = [(NSURL *)[info valueForKey:UIImagePickerControllerMediaURL] absoluteString];
*NSLog(@"didFinishPickingMediaWithInfo: %@",tempFilePath);
*// e.g. /private/var/mobile/Applications/D1E784A4-EC1A-402B-81BF-F36D3A08A332/tmp/capture/capturedvideo.MOV
*tempFilePath = [[tempFilePath substringFromIndex:16] retain];
*NSLog(@"didFinishPickingMediaWithInfo: %@",tempFilePath);
*NSLog(@"===Try to save video to camera roll.===");
*NSLog(@"UIVideoAtPathIsCompatibleWithSavedPhotosAlbum: %@",UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(tempFilePath)? @"YES":@"NO");
*// Check if the video file can be saved to camera roll.
* * if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(tempFilePath)){
* // YES. Copy it to the camera roll.
* UISaveVideoAtPathToSavedPhotosAlbum(tempFilePath, self, @selector(video:didFinishSavingWithError:contextInfo:), tempFilePath);
*}

*[self dismissModalViewControllerAnimated:YES];
}

- (void)video:(NSString *)videoPath didFinishSavingWithError:(NSError *)error contextInfo:(NSString *)contextInfo{
*NSLog(@"didFinishSavingWithError--videoPath in camera roll:%@",videoPath);
*NSLog(@"didFinishSavingWithError--videoPath in temp directory:%@",contextInfo);
*// The thumbnail jpg should located in this directory.
*NSString *thumbnailDirectory = [[contextInfo stringByDeletingLastPathComponent] stringByDeletingLastPathComponent];

*// Debug info. list all files in the directory of the video file.
*// e.g. /private/var/mobile/Applications/D1E784A4-EC1A-402B-81BF-F36D3A08A332/tmp/capture
*NSLog([contextInfo stringByDeletingLastPathComponent]);
*NSLog([[[NSFileManager defaultManager] contentsOfDirectoryAtPath:[contextInfo stringByDeletingLastPathComponent] error:nil] description]);
*// Debug info. list all files in the parent directory of the video file, i.e. the "~/tmp" directory.
*// e.g. /private/var/mobile/Applications/D1E784A4-EC1A-402B-81BF-F36D3A08A332/tmp
*NSLog(thumbnailDirectory);
*NSLog([[[NSFileManager defaultManager] contentsOfDirectoryAtPath:thumbnailDirectory error:nil] description]);
*///////////////////

*// Find the thumbnail for the video just recorded.
*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 jpg extension.
* if ([[file pathExtension] isEqualToString: @"jpg"]) {
* *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 thumbnail path.
*latestFile = [NSTemporaryDirectory() stringByAppendingPathComponent:latestFile];
*NSLog(@"****** The thumbnail file should be this one:%@",latestFile);

*// Your code ...
*// Your code ...
*// Your code ...
}
that was from another post I found, havnt had time to test yet
mrburns05 is offline   Reply With Quote
 

» Advertisements
» Online Users: 331
15 members and 316 guests
.Snipe, acegames, baja_yu, Bertrand21, chemistry, Domele, fredbmm, garticle, greeneye82, HemiMG, jimmyon122, mobilaga, Newbie123, Plazor, zhijianhi
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,555
Threads: 94,078
Posts: 402,736
Top Poster: BrianSlick (7,990)
Welcome to our newest member, garticle
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 08:03 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.