iphone - MPMoviePlayer 流式视频缓冲区大小

标签 iphone ios streaming buffer mpmovieplayer

有没有办法检测在 MPMoviePlayerController 中播放视频时缓冲了多少数据?

我已经检查了 loadState,但这并没有给我足够的缓冲信息。

Youtube 的应用正是我想要的...

最佳答案

您可以尝试在播放视频的过程中获取电影访问日志。

- (void)calculateBufferSize
{
    NSArray *events = self.moviePlayerController.accessLog.events;
    int count = events.count;
    for (int i = 0; i < count; i++)
    {
        MPMovieAccessLogEvent *currentEvent = [events objectAtIndex:i];
        int64_t byte = currentEvent.numberOfBytesTransferred;
        int64_t bytes = currentEvent.numberOfBytesTransferred >> 10;

        NSLog(@"byte = %f M bytes = %lld", (float)byte / (1024 * 1024), bytes);
    }
}

然后你可以调用上面的方法,例如,

[NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(calculateBufferSize) userInfo:nil repeats:YES];

之后

[self.moviePlayerController play];

https://developer.apple.com/library/ios/#DOCUMENTATION/MediaPlayer/Reference/MPMovieAccessLog_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40010561

关于iphone - MPMoviePlayer 流式视频缓冲区大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14066088/

相关文章:

iphone - 什么是私有(private)框架以及我们将如何使用它们?

ios - 带有显示 UIPickerView 的 inputView 的 UITextField...如何在 IOS 7 中关闭半透明?

iphone - 圆 UIView 角落的最佳和最快方法?

iphone - 如何动态创建多个按钮并处理它们单独的事件? + iPhone SDK

ios - 无法显示用户当前位置 Mapbox iOS API

java - 将视频流式传输到服务器

python - 在 hadoop 上的一个流作业中使用多个映射器输入?

iphone - 以编程方式创建 UITableViewCell 还是从 nib 加载一个更快?

iOS 8 : Remove Underline from UITableViewRowAction

audio - 获取 Icecast 歌曲标题而不缓冲音频