gpt4 book ai didi

iPhone:从iPhone库导入视频

转载 作者:行者123 更新时间:2023-12-03 19:41:36 24 4
gpt4 key购买 nike

我正在我的应用程序中从 iphone 库导入视频...但我无法显示我在堆栈溢出流上研究了很多代码,但没有一个起作用..对我来说..基本上我正在 Facebook 上进行共享推特.....

-(IBAction)showVideoLibrary
{
UIImagePickerController *videoPicker = [[UIImagePickerController alloc] init];
videoPicker.delegate = self;
videoPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

videoPicker.mediaTypes =[[NSArray alloc] initWithObjects: (NSString *)kUTTypeMovie,nil];    
if(self.popoverController!=nil)
{
   [self.popoverController release];
}
self.popoverController  = [[UIPopoverController alloc] initWithContentViewController:videoPicker];
popoverController.delegate = self;
popoverController.popoverContentSize=CGSizeMake(320,1000);

[popoverController presentPopoverFromRect:CGRectMake(0,0,10,10) inView:self.view permittedArrowDirections:nil animated:YES];

}

提前致谢

最佳答案

在真实的 iPhone 设备上尝试一下。这是从我的项目中使用的 iPhone 库中挑选视频的代码。只需将选择器中的视频方法添加到您所需的按钮即可。

-(void)video
{
UIImagePickerController *imagePicker =
[[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType =
UIImagePickerControllerSourceTypePhotoLibrary;


imagePicker.mediaTypes = [[NSArray alloc] initWithObjects:(NSString *)kUTTypeMovie, nil];

[self presentModalViewController:imagePicker animated:YES];


}


-(void) imagePickerController: (UIImagePickerController *) picker
didFinishPickingMediaWithInfo: (NSDictionary *) info
{


NSString *mediaType = [info objectForKey: UIImagePickerControllerMediaType];

if (CFStringCompare ((__bridge CFStringRef) mediaType, kUTTypeMovie, 0)
== kCFCompareEqualTo)
{

NSString *moviePath = [[info objectForKey:UIImagePickerControllerMediaURL] path];

NSURL *videoUrl=(NSURL*)[info objectForKey:UIImagePickerControllerMediaURL];
// NSLog(@"%@",moviePath);

if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum (moviePath)) {
UISaveVideoAtPathToSavedPhotosAlbum (moviePath, nil, nil, nil);
}
}


[self dismissModalViewControllerAnimated:YES];

[picker release];


}

不要忘记添加移动核心服务框架并导入

 #import <MobileCoreServices/UTCoreTypes.h>

字符串“moviepath”为您提供该 iPhone 中视频的路径,然后对该视频执行任何所需的操作在字符串电影路径中压缩完成后,您将获得视频路径在此处输入代码

 MPMoviePlayerController *player =[[MPMoviePlayerController alloc] initWithContentURL: url];   //  give here the "videourl"  
[[player view] setFrame: [self.view bounds]];
[self.view addSubview: [player view]];
[player play];

关于iPhone:从iPhone库导入视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10616602/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com