views:

81

answers:

1

Basically i record / import video , it saves to the docs folder and im trying to figure out how to get the length (time) so i can display it for each individual video..

I have a column in the database for it and the neccessary code to display it, just not sure how to get it..

Any help is greatly appreciated

+3  A: 

You can get the path to the document and pass it as a file URL into the MediaPlayer framework to get info about the video file. Here's code to get the duration in seconds of a movie file:

NSArray *docsPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsFolder = [docsPaths objectAtIndex:0];
NSString *movieFilePath = [documentsFolder stringByAppendingPathComponent:@"Movie.mov"];
MPMoviePlayerController *player = [[[MPMoviePlayerController alloc] initWithContentURL] autorelease];
NSTimeInterval duration = player.duration; // in seconds
lucius
Thank you! Much appreciated!
mrburns05