我有奇怪的MPMoviePlayerController行爲。它不想播放從UIImagePickerController的Camera Roll中選擇的電影。但是當我用UIImagePickerController捕捉電影時 - 有時它會在MPMoviePlayerController中播放。MPMoviePlayerController不播放從UIImagePickerController挑選的電影
這是的UIImagePickerController初始化:
mediaPickerController = [[[UIImagePickerController alloc] init] autorelease];
NSArray *types = [UIImagePickerController availableMediaTypesForSourceType:sourceType];
mediaPickerController.sourceType = sourceType;
mediaPickerController.mediaTypes = types;
mediaPickerController.videoQuality = qualityType;
mediaPickerController.delegate = self;
[self presentModalViewController:mediaPickerController animated:YES];
這是- (空)imagePickerController:(的UIImagePickerController *)選擇器didFinishPickingMediaWithInfo:(NSDictionary的*)信息委託方法:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSURL *fileURL = [info objectForKey:UIImagePickerControllerMediaURL];
playerView = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
[playerView.view setFrame:mediaPreview.bounds];
[playerView setScalingMode:MPMovieScalingModeAspectFit];
[playerView setControlStyle:MPMovieControlStyleEmbedded];
[playerView setShouldAutoplay:NO];
[playerView prepareToPlay];
[mediaPreview addSubview:playerView.view];
}
另一個奇怪問題 - 當我使用UIImagePickerController的sourceType = Camera,然後委託返回下一個路徑並播放良好:
UIImagePickerControllerMediaURL = "file://localhost/private/var/mobile/Applications/XXXXX-XXXXX/tmp/capture-T0x127bb0.tmp.5gFkOo/capturedvideo.MOV"
但當sourceType的=庫,路徑看上去不正確和電影在半出現第二和消失:
UIImagePickerControllerMediaURL = "file://localhost/private/var/mobile/Applications/XXXXX-XXXXX/tmp//trim.ZPeyTU.MOV"
有什麼想法?
非常感謝你的回答。 [picker release]解決了我的問題。 – konradowy
@mikewoz:謝謝你的主意。我相信這可以在iPad上提供幫助,但這種方法無法解決iPhone 3G和3GS設備上的問題。目前,我暫時使用縮略圖圖片進行預覽,因爲我的應用程序應該可以在iPad(iPhone 3G上)以及傳統設備上使用。 – SVGreg