2011-08-17 2 views
3

내 APP에 UISaveVideoAtPathToSavedPhotosAlbum을 사용하여 사진 라이브러리에 비디오를 저장하고 있습니다. 동영상 경로가 표시되지만이 동영상을 재생할 수 없습니다. 어느 누구도 저장된 비디오를 검색하는 방법에 대해이 문제를 해결할 수 있습니까? 사전에 감사드립니다. 아래 코드를 사용했습니다.UISaveVideoAtPathToSavedPhotosAlbum에서 비디오를 검색하는 방법

-(IBAction) getPhoto:(id) sender { 
    UIImagePickerController * picker = [[UIImagePickerController alloc] init]; 
    picker.delegate = self; 

    if((UIButton *) sender == choosePhotoBtn) { 
    picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum; 
    picker.mediaTypes = [NSArray arrayWithObjects:(NSString *)kUTTypeMovie, (NSString *)kUTTypeImage, nil]; 

} else { 
    picker.mediaTypes = [NSArray arrayWithObjects:(NSString *)kUTTypeMovie, (NSString *)kUTTypeImage, nil]; 
    picker.sourceType = UIImagePickerControllerSourceTypeCamera; 
    } 

[self presentModalViewController:picker animated:YES]; 
} 

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

     NSString *tempFilePath = [[info objectForKey:UIImagePickerControllerMediaURL] path]; 
     UISaveVideoAtPathToSavedPhotosAlbum(tempFilePath, self, @selector(video:didFinishSavingWithError:contextInfo:), nil); 
     NSLog(@"temp path %@",tempFilePath); 
     [picker dismissModalViewControllerAnimated:YES]; 

} 

답변

1

NSURL * url = [NSURL fileURLWithPath : tempFilePath]; 및 "MPMoviePlayerController"를 사용하여 재생 :

1

이 함수에서 반환하는 경로에는 접미사가 필요합니다. 시도해보십시오

NSString *videoPath = [[info objectForKey:UIImagePickerControllerMediaURL] path]; 
NSURL *videoURL = [NSURL URLWithString:[NSString stringWithFormat:@"file://localhost%@", videoPath]];