Developing an application for the iPhone, how to get the video “length” from the video saved in my application docs folder?

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

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

Any help is appreciated

+3
source share
1 answer

URL- MediaPlayer, . , :

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
+7

Source: https://habr.com/ru/post/1746298/


All Articles