gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 05:23:13 25 4
gpt4 key购买 nike

有没有办法检测在 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com