iphone - 如何将视频添加到iPad模拟器? [英] iphone - How do I add videos to iPad simulator?

查看:363
本文介绍了iphone - 如何将视频添加到iPad模拟器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不,将视频放到

~/Library/Application Support/iPhone Simulator/3.2/Media/DCIM/100APPLE

完全不起作用,因为模拟器可以在Photos.app上看到视频,但是当我尝试使用UIImagePickerController选择视频我的应用程序崩溃。

does not work totally, because the simulator can see the video on Photos.app, but when I try to pick a video using UIImagePickerController my application crashes.

我认为这可能与视频必须具有的格式有关。我正在使用QuickTime生成视频。我正在使用for iPhone设置...所以它正在生成一个480x360像素H264的M4V。我试图创建一个具有相同特征的MOV和一个640x480的MOV,但没有任何作用。我还放弃了用iPhone 3GS创建的电影,但它仍然崩溃。

I think this may have some relation to the format the video has to have. I am using QuickTime to generate the video. I am using the settings "for iPhone"... so it is generating a M4V with 480x360 pixels H264. I have tried to create a MOV with the same characteristics and one with 640x480 but nothing works. I have also dropped a movie created with iPhone 3GS and it still crashes.

我的文件名为VID_0001.MOV,全部为大写。

I have the file named as VID_0001.MOV, all uppercase.

这是我崩溃时看到的错误

this is the error I see when it crashes


***终止应用由于未捕获的异常'NSRangeException',原因:'*** - [NSCFArray objectAtIndex:]:index(1)超出边界(0)'

从不调用方法 didFinishPickingMediaWithInfo ,因此它在模拟器或视频上有些问题。我选择视频时应用程序崩溃了。

the method didFinishPickingMediaWithInfo is never called, so its some issue on the simulator or on the video. The app crashes as soon as I pick the video.

此问题没有解决方案?来吧!伙计们! : - )

No solution for this question? c'mon guys! :-)

谢谢。

推荐答案

花了一秒钟(和一些狡猾)但我明白了。将视频文件放入应用程序的Documents目录中,我尝试了一个.MOV但是没有用,一个.m4v工作。然后把它放在你的应用程序中(我只是把它放在应用程序中:didFinishLaunchingWithOptions):

Took a sec (and some deviousness) but I figured it out. Put a video file into your application's Documents directory, I tried a .MOV but that didn't work, a .m4v worked. Then put this early in your app (I just stuck it in application:didFinishLaunchingWithOptions):

    NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"Documents/myMovie.m4v"]];
    UISaveVideoAtPathToSavedPhotosAlbum(path, self, @selector(video:didFinishSavingWithError:contextInfo:), nil);

并添加此功能(以便您可以查看是否发生错误以及原因):

And add this function (so you can see if an error happened and why):

- (void)video:(NSString *)videoPath didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo {
    if (error != nil) {
        NSLog(@"Error: %@", error);
    }
}

工作就像一个魅力,我现在有一个视频我在模拟器上保存了已保存的照片。

Worked like a charm, I now have a video in my 'Saved Photos' on the simulator.

这篇关于iphone - 如何将视频添加到iPad模拟器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆