iphone - How do I add videos to iPad simulator?
Solution 1
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.
Solution 2
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.
Solution 3
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!
Solution 4
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.)
Related videos on Youtube
Duck
Updated on April 18, 2022Comments
-
Duck about 2 years
No, dropping the videos to
~/Library/Application Support/iPhone Simulator/3.2/Media/DCIM/100APPLE
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.
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.
I have the file named as VID_0001.MOV, all uppercase.
this is the error I see when it crashes
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSCFArray objectAtIndex:]: index (1) beyond bounds (0)'
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! :-)
thanks.
-
Raj Pawan Gumdal about 14 yearsHey Mike, are you sure dropping a m4v video to simulator location: "~/Library/Application Support/iPhone Simulator/3.2/Media/DCIM/100APPLE" will display the video in Photos application? I am not able to add video to iPhone Simulator, any suggestions?
-
-
Adam over 13 yearsWorked great. To find a video that would work, I tried them out in QuickTime first - if QT could open it, and do a file-save-as "iPhone", that worked. Vids that QT couldn't open (missing codec), I gave up tryign to get onto iPhone - but I just needed something for debugging :)
-
Leena over 12 yearsthanks it worked for me but i saved .3gp video .m4v file did n't worked for me.
-
dev_jac over 11 yearsIt's easier to just drop the video onto the project and replace the first line of code with this:
NSString* path = [[NSBundle mainBundle] pathForResource:@"myMovie" ofType:@"m4v"];
-
the_summer_bee about 11 yearsHi, where exactly do I place the m4v?
-
alones almost 11 yearsit works correctly as you said in iOS 6 Simulator. But it does not work in iOS 5 Simularot. Thank you for sharing!
-
Denis Kutlubaev almost 11 yearsThis is a better solution. I was searching for something like this.
-
cynistersix almost 10 yearson iOS 7 simulator hit the export button at the top left
-
Mark almost 10 yearsWorks great on iOS8 simulator too. Saved me heaps of time digging around hidden folders and having to write code snippets to import it.