I am looking for a way to programmatically access movies in my documents or movies directory of my iPad, rather than bundling them into the Resources directory. I am programming an iPad application that is heavily dependent on movies, and is intended to be an inhouse demo tool (it will be distributed to only a few iPads in the company). With the movies bundled in to the app, it’s almost a full Gig in size. I can’t find any way to automatically load a file without placing it in the Resources directory:
NSString *path = [[NSBundle mainBundle] pathForResource:name ofType:@"m4v"];
MPMoviePlayerViewController *thisplayer = [[MPMoviePlayerViewController alloc]
initWithContentURL:[NSURL fileURLWithPath:path]];
[self presentMoviePlayerViewControllerAnimated:thisplayer];
Am I missing something, or is there a security-driven limitation that won’t allow me to use the movies directory? Much apologies if I have brainfarted.
You can use the
ALAssetsLibraryclass to get programmatic access to the movies stored on the user’s device. (Alternatively, you can use a media picker to let the user choose which asset to use; then you’ll be given a URL which you can load the movie from.)