有没有办法检测在MPMoviePlayerController
中流式传输视频时缓冲了多少数据?
我已经检查了loadState
,但这并没有给我足够的缓冲信息。
Youtube的应用程序正是我想要的......
答案 0 :(得分:7)
您可以尝试在播放视频时获取电影访问日志。
- (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];