2012-04-18 134 views
0

我有以下代碼,它保存從相機膠捲中選擇的UIImage或視頻。使用從AVRURLAsset從相機膠捲保存的視頻 - initWithURL - iPhone

NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType]; 

[self dismissModalViewControllerAnimated:YES]; 

if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) { 
    introImage = [info objectForKey:UIImagePickerControllerOriginalImage]; 

    //Unhide our UIImage Preview and insert our chosen Video or Intro. 
    selectIntroButton.hidden = YES; 
    selectedIntro.hidden = NO; 
    cancelIntroChoiceButton.hidden = NO; 
    selectedIntro.image = introImage; 
} 
else if ([mediaType isEqualToString:(NSString *)kUTTypeMovie]) 
{ 

    //Create variable for video. 

    AVURLAsset *asset=[[AVURLAsset alloc] initWithURL:??? options:nil]; 
    AVAssetImageGenerator *generator = [[AVAssetImageGenerator alloc] initWithAsset:asset]; 
    generator.appliesPreferredTrackTransform=TRUE; 
    [asset release]; 
    CMTime thumbTime = CMTimeMakeWithSeconds(0,30); 

我的問題是如何將所選視頻提供給AVURLAssset initWithURL?什麼類型的對象是[info objectForKey:UIImagePickerControllerOriginalImage]返回?

謝謝。

回答

0

您可以通過UIImagePickerControllerReferenceURL鍵獲取資產的URL。

[[AVURLAsset alloc] initWithURL:[info objectForKey:UIImagePickerControllerReferenceURL]]

相關問題