我有奇怪的MPMoviePlayerController行为。它不想播放仅从UIImagePickerController的“相机胶卷”中选择的电影。但是,当我使用UIImagePickerController捕获电影时,有时可以在MPMoviePlayerController中正常播放。
这是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];
这是-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info 委托方法:
- (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 = Library时,路径看起来不正确,电影会在半秒钟后出现并消失:
UIImagePickerControllerMediaURL = "file://localhost/private/var/mobile/Applications/XXXXX-XXXXX/tmp//trim.ZPeyTU.MOV"
有什么想法吗?
最佳答案
我有同样的事情,只发生在iPad 2上,而相同的确切代码在iPhone 4上却可以正常工作。
原来,返回视频后,图像选择器没有被正确释放。
尝试在didFinishPickingMediaWithInfo回调中添加[picker版本]。
关于iphone - MPMoviePlayerController不播放从UIImagePickerController拾取的电影,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/6455299/