2011-08-17 12 views
3

私のアプリでは、ビデオを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"を使用してURLを再生

1

この関数によって返されるパスには、接尾辞が必要です。これを試してください

NSString *videoPath = [[info objectForKey:UIImagePickerControllerMediaURL] path]; 
NSURL *videoURL = [NSURL URLWithString:[NSString stringWithFormat:@"file://localhost%@", videoPath]]; 
関連する問題