views:

895

answers:

3

Hi everyone,

The question is - how to get the movie length from MPMoviePlayerController object?

I need this to create a progress bar. I have the method [myPlayer currentTime] to move progress bar while movie is playing. And the [myPlayer setCurrentTime: doubleVal] to rewind the movie. But I can't use all this without information about movie length, or movie end time.

Also, maybe exists another player to use in iPhone, instead of MPMoviePlayerController?

A: 

If you have the URL of your movie you can use NSDatas initWithURL, this will give you a NSData object with the bytes of the movie, you can use [data length] in order to get the number of bytes in the movie, hope that helps!

Daniel
A: 

Thanks Daniel,

But what if we have two movies with 2 minutes in length. But one of them will be in bad quality and another in good. So I will obtain different [data length] values, although they both 2 minutes in length

Dmitry
A: 

You will found the answer in given link below.

http://stackoverflow.com/questions/1214958/how-do-you-get-an-iphone-mpmovieplayer-videos-total-time

sugar