2011-10-27 11 views
5

Tengo una aplicación donde estoy grabando un video. Pero cuando termina la grabación, no puedo guardar el video inmediatamente. Necesito mostrar un acuerdo primero. Así que trato de guardar la URL que obtengo del selector de imágenes. Y guarde el video en la biblioteca más tarde. Esto funcionó bien en iOS4, pero no en iOS5. Soy nuevo en iOS y Objective-C, así que probablemente hice una declaración totalmente incorrecta de la propiedad que se supone que contiene la URL.Almacenamiento de la URL del video grabado para guardar en la biblioteca más adelante

Esta es una parte del código:

.h

#import <UIKit/UIKit.h> 
#import <AssetsLibrary/AssetsLibrary.h> 


@interface Video_recViewController : UIViewController <UIImagePickerControllerDelegate, UINavigationControllerDelegate, UIActionSheetDelegate> { 

NSURL *tempMoviePath; 

} 


@property (nonatomic, retain) NSURL *tempMoviePath; 

.m

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { 

NSURL *moviePath = [info objectForKey:UIImagePickerControllerMediaURL]; 
[self dismissModalViewControllerAnimated: YES]; 
NSLog(@"path from image picker: %@", moviePath); 
tempMoviePath = moviePath; 
NSLog(@"temp movie path: %@", tempMoviePath); 
// 
[self performSelector:@selector(showAgree) withObject:nil afterDelay:0.5]; 

} 

- (void)userAgreed { 
NSLog(@"user agreed"); 
//NSLog(@"temp movie path: %@", tempMoviePath); 
[self saveMyVideo:tempMoviePath]; 
//[self performSelector:@selector(showSurvey) withObject:nil afterDelay:0.5]; 
} 

- (void)saveMyVideo:(NSURL *)videoURL { 

NSLog(@"saving movie at: %@", videoURL); 

ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init]; 
if ([library videoAtPathIsCompatibleWithSavedPhotosAlbum:videoURL]) 
{ 
    [library writeVideoAtPathToSavedPhotosAlbum:videoURL 
           completionBlock:^(NSURL *assetURL, NSError *error){} 
    ]; 
} 
[library release]; 

} 

salida del registro cuando didFinishPickingMediaWithInfo es:

temp movie path: file://localhost/private/var/mobile/Applications/8CFD1CB7-70A0-465C-B730-817ACE5A4F78/tmp/capture-T0x119660.tmp.hNFzkY/capturedvideo.MOV 

salida de la log cuando d oing "saveMyVideo". ¡La URL se ha convertido repentinamente en esto! :

saving movie at: (
"0.31269", 
"0.32899", 
"0.63999", 
"0.33001", 
"0.3", 
"0.6", 
"0.15", 
"0.05999" 
) 

Respuesta

0

(. Contestada por el PO en una pregunta de edición Ver Question with no answers, but issue solved in the comments (or extended in chat))

La OP escribió:

El código incorrecto fue:

tempMoviePath = moviePath; 

Porque estoy estableciendo una propiedad declarada, debo se el conjunto & obtener métodos. Debería ser:

[self setTempMoviePath:moviePath]; 

Al parecer iOS 4 no era tan duro en esto, pero IOS5 no puede manejarlo. Pero, de todos modos, estaba mal escribir así. Admito mi error. :)

Cuestiones relacionadas