Reputation: 13
I recorded a video and copied it to the path
NSURL *videoPath =[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUsersDomainMask,YES) objectAtIndex:0],@"/output.mov"]];
Then use MPMoviePlayer to play it:
MPMoviePlayerController *player = [[MPMovieController alloc] initWithContentURL:videoPath];
This does not work. The video can't get loaded. The file path is
"/var/mobile/Applications/12341235-12354125-123412-41/Documents/output.mov"
Does anyone know why?
Upvotes: 1
Views: 797
Reputation: 2481
i think you forgot to set / for your file path use like this
NSURL *videoPath =[NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/%@",[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUsersDomainMask,YES) objectAtIndex:0],@"output.mov"]];
Upvotes: 0
Reputation: 18670
For some weird reason, MPMoviePlayerController
doesn't seem to like certain NSURL
s even though they are deemed as valid objects.
The "secret" is to get the file path as NSString
and then use [NSURL fileURLWithPath:URLStringPath]
to create the URLs your are using to create the MPMoviePlayerController
instance.
Upvotes: 8