Desperated. Hello! I am having some problems with MPMoviePlayerController. I did this while working with a video from NSBundle. But that is not what I need. I need to play it from the Documents directory, because this is the place where I store recorded videos whose URLs are stored in CoreData. but let's leave this aside and simplify the code to the minimum necessary. This code actually WORKS if the contentURL that leads to the NSBundle is used. After that, what am I doing to get to the place of documents. What am I doing:
NSURL *contentURL = [[NSBundle mainBundle] URLForResource:@"Oct_08_2012_10_00_51" withExtension:@"mp4"]; // this works NSString* docPath = [NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; NSString * docaPathFull = [NSString stringWithFormat:@"%@%@", docPath, @"/Oct_08_2012_10_00_51.mp4"]; NSURL * docUrl= [NSURL URLWithString: docaPathFull]; BOOL ex = [[NSFileManager defaultManager] fileExistsAtPath:docaPathFull]; NSLog(@"file exists: %d, path using docPath: %@",ex, docaPathFull); MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:docUrl]; player.shouldAutoplay = YES; player.controlStyle = MPMovieControlStyleEmbedded; [player.view setFrame: self.thumbButton.bounds]; [player prepareToPlay]; [self.view addSubview: player.view]; [player play];
What do we have:
2012-10-08 13:14:43.532 Voto[11968:907] file exists: 1, path using docPath: /var/mobile/Applications/07B8574A-A3BA-4B23-BB3F-995B33A01B95/Documents/Oct_08_2012_10_00_51.mp4 2012-10-08 13:14:43.907 Voto[11968:907] content URL: file://localhost/var/mobile/Applications/07B8574A-A3BA-4B23-BB3F-995B33A01B95/Voto.app/Oct_08_2012_10_00_51.mp4 2012-10-08 13:14:44.265 Voto[11968:907] doc URL: /var/mobile/Applications/07B8574A-A3BA-4B23-BB3F-995B33A01B95/Documents/Oct_08_2012_10_00_51.mp4 2012-10-08 13:14:45.343 Voto[11968:907] [MPAVController] Autoplay: Disabling autoplay for pause 2012-10-08 13:14:45.344 Voto[11968:907] [MPAVController] Autoplay: Disabling autoplay 2012-10-08 13:14:46.518 Voto[11968:907] [MPAVController] Autoplay: Skipping autoplay, disabled (for current item: 1, on player: 0) 2012-10-08 13:14:46.540 Voto[11968:907] [MPAVController] Autoplay: Enabling autoplay 2012-10-08 13:14:46.554 Voto[11968:907] [MPAVController] Autoplay: Likely to keep up or full buffer: 0 2012-10-08 13:14:46.555 Voto[11968:907] [MPAVController] Autoplay: Skipping autoplay, not enough buffered to keep up. 2012-10-08 13:14:46.557 Voto[11968:907] [MPAVController] Autoplay: Enabling autoplay 2012-10-08 13:14:46.567 Voto[11968:907] [MPCloudAssetDownloadController] Prioritization requested for media item ID: 0 2012-10-08 13:14:46.871 Voto[11968:907] [MPAVController] Autoplay: Enabling autoplay
So the file exists ... The questions I looked at:
MPMoviePlayer downloads and plays movies saved in application documents
MPMoviePlayerController does not work with movie in document folder
MPMoviePlayerViewController plays a movie from a document catalog - objective-c
I also checked ut with a reference to the class, nothing concrete about how to play from documents. Settings for my projects: using the latest version of iOS 6, Deployment Goal 5.0 Testing on iOS6 iPhone simulator and iPad with iOS 6. If I forgot to add something, please remind me, I will do it immediately.
Please, help!:)
source share