2

I am playing videos from our web server and I'm using the MPMoviePlayerController to play it. It first, downloaded the file while simultaneously playing it.

I need to post a log back in our web server every time a video reaches the 10% mark while downloading the file. How would I know that the downloading of the file reaches 10%? By the way, I already got the file size and already computed the 10th percent of any file, All I want to know is when will I be able to know that it already downloaded 10% of the file? Thanks

Jahn
  • 97
  • 2
  • 10

1 Answers1

7

Try it using the playableDuration duration of MPMoviePlayerController. When using this in conjunction with the duration property, you should roughly get an idea if 10% of the entire download are reached.

From the MPMoviePlayerController reference:

playableDuration

The amount of currently playable content. (read-only)

@property (nonatomic, readonly) NSTimeInterval playableDuration

Discussion

For progressively downloaded network content, this property reflects the amount of content that can be played now.

Example:

The following code could be run within a timer, triggered with a delay of 1 second on less, depending on the accuracy you actually need this functionality to have.

if (player.duration > 0.0 && player.playableDuration > 0.0)
{
    if (player.playableDuration >= player.duration / 10.0)
    {
        //we just reached 10% of the total movie playtime
    )
}
Till
  • 27,559
  • 13
  • 88
  • 122
  • Thanks. This works perfectly. Just one issue that user needs to tap on `MPMoviePlayerController` in order to see the controls. I need to start the movie when user clicks on `Play` button. Do you know any solution by which we can show controls automatically ? – iOSAppDev Aug 12 '14 at 09:38