Can anyone tell me how to add video the iPhone simulator so that I can test some apps I am working on? Thanks in advance!
You can add Your file by adding these 2 lines of code in appdelegate.m
NSString *path = [[NSBundle mainBundle] pathForResource:@"sample_iTunes" ofType:@"mov"];
UISaveVideoAtPathToSavedPhotosAlbum(path, self, @selector(video:didFinishSavingWithError:contextInfo:), nil);`
go to following path and past video
/Users/"username"/Library/Developer/CoreSimulator/Devices/11BFF1F0-2A2B-409A-9727-3267D71E10D4/data/Media
If you're asking how to add video to your app the simple way to show video using MediaPlayer.h
lib.
// fileURL is a NSURL made from file path in app bundle
MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL: fileURL];
[[mp view] setFrame:CGRectMake(0,0,100,100)];
[mp play];
You should set many parameters for mp object: scaling, controls, etc.
okey, try this:
- (void) downloadVideo {
NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://sepwww.stanford.edu/sep/jon/trash/poolwaves.mov"]];
You can change the temp.mov to temp.m4v to save the vid in m4v.
NSString *tempPath = [NSString stringWithFormat:@"%@/temp.mov", NSTemporaryDirectory()];
[imageData writeToFile:tempPath atomically:NO];
UISaveVideoAtPathToSavedPhotosAlbum (tempPath, self, @selector(video:didFinishSavingWithError: contextInfo:), nil);
}
- (void) video: (NSString *) videoPath
didFinishSavingWithError: (NSError *) error
contextInfo: (void *) contextInfo {
NSLog(@"Finished saving video with error: %@", error);
}
if you change the url to your moviefile, this should work really well...
the movies are saved in this directory: /Library/Application Support/iPhone Simulator/4.3.2/Media/DCIM
but you are right, if i copy a file to it, it won't show up in the simulator
greets
It's very simple you just drag any .MOV file to your simulator. Now it will be opened in Safari browser. At top left corner there is a 'Done' button. You just have to press it after this you can press Share button then just choose the option save video and it's done. Now play it in your app. :)
You need to add video in your application bundle itself. Later you can copy that to the documents directory.