MPMoviePlayerController: when will I know that the downloading of the file reaches 10 percent?

喜夏-厌秋 提交于 2019-12-02 02:45:01

问题


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


回答1:


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


来源:https://stackoverflow.com/questions/10346327/mpmovieplayercontroller-when-will-i-know-that-the-downloading-of-the-file-reach

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!