【发布时间】:2010-12-26 02:30:22
【问题描述】:
我有一个 UIPickerController 可以在我的应用程序中选择视频,但在使用选择器选择视频时它会崩溃。当我直接向 MPMoviePlayerController 提供 URL 时,它可以正常工作,但是当 URL 来自 UIPickerController 时,它会正确加载电影,但在创建缩略图时会崩溃。
在选择文件之后,我已将 URL 转储到控制台,这就是我所看到的
file://localhost/private/var/mobile/Applications/FA667F85-B009-46FA-A0B9-A7345A072651/tmp//trim.Ir0gqx.MOV
第一个问题:为什么文件名前有双杠? 第二个问题:如果我在选择器上编辑 NO,为什么文件名带有修剪前缀?
这是选择器代码:
- (void) selectMovie:(id) sender {
if ([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypePhotoLibrary]) {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
NSArray *mediaTypesAllowed = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
picker.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeMovie, nil];
picker.delegate = self;
picker.allowsEditing = NO;
picker.videoQuality = UIImagePickerControllerQualityTypeHigh; // I've added this trying to make it stop compressing the video, but it won't... any clues?
UIPopoverController *aPopover =
[[UIPopoverController alloc] initWithContentViewController:picker];
aPopover.delegate = self;
CGRect myRect = [sender frame];
[aPopover presentPopoverFromRect:myRect inView:self.view permittedArrowDirections:UIPopoverArrowDirectionRight animated:YES];
}
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSString* mediaType = [info objectForKey:UIImagePickerControllerMediaType];
if ( [ mediaType isEqualToString:@"public.movie" ]){
movieURL = [info objectForKey:UIImagePickerControllerMediaURL];
}
NSLog(@"%@", movieURL);
[self loadMovie:movieURL];
}
【问题讨论】:
-
file://是来自 UIPicker 还是来自您直接粘贴? -
它来自选择器...但奇怪的是文件名之前的末尾/...但它似乎是正确的。
标签: iphone ipad uiimagepickercontroller mpmovieplayercontroller