MPMoviePlayerController:什么时候知道文件下载量达到10%? [英] MPMoviePlayerController: when will I know that the downloading of the file reaches 10 percent?

查看:81
本文介绍了MPMoviePlayerController:什么时候知道文件下载量达到10%?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从Web服务器上播放视频,并且正在使用MPMoviePlayerController进行播放.首先,在下载文件的同时播放它.

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.

每次下载文件时,视频达到10%标记时,我都需要在Web服务器上发布日志.我怎么知道文件下载量达到10%?顺便说一句,我已经掌握了文件大小,并且已经计算出任何文件的10%,我想知道的是什么时候才能知道它已经下载了文件的10%?谢谢

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

推荐答案

使用MPMoviePlayerControllerplayableDuration持续时间尝试.将此属性与duration属性一起使用时,您应该大致了解一下是否达到了整个下载量的10%.

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.

MPMoviePlayerController参考:

playableDuration

当前可播放内容的数量. (只读)

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

@property (nonatomic, readonly) NSTimeInterval playableDuration

讨论

对于逐步下载的网络内容,此属性 反映出现在可以播放的内容量.

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

示例:

以下代码可以在计时器中运行,延迟时间为1秒或更短,具体取决于您实际需要此功能的精度.

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

这篇关于MPMoviePlayerController:什么时候知道文件下载量达到10%?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆