iphone - How do I add videos to iPad simulator?

久未见 提交于 2019-11-27 10:58:17

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.

Download any video that have extension .mov onto your desktop. Then open simulator, drag and drop video into simulator. Video will play after that.

Now, you can stop the video and save it into camera roll.

This is the way to do it:

First Drag and drop a image or movie into the Simulator window and safari will open with the image you droped in. Then press the share button in the safari tool bar and then click the "Save To Camera Roll Button" and then go to your home Screen and click on the photos app (the one with the flower on it) and go to your saved Photos and there it is!

As of iOS 12, the trick seems to be opening mobile Safari, dragging the .mov file onto it in the simulator, and then it opens up the Photos app and you'll see the video there. (Dragging and dropping directly on the Photos app doesn't work for me, for some reason.)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!