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
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
)
}