在模拟器上通过得到MPMovieAccessLogEvent,可以得到当时播放视频缓冲的大小和传输速率, 分别为:numberOfBytesTransferred 、indicatedBitrate, 其中第一个的单位为byte, 第二个的单位为bits 从模拟器上测试结果来看events.count,总是为1 这样的话我们就可以得到视频当前缓冲的数据,但是当在真机上测试的时候总是取不到值 难道因为他是log,在release模式下就没了?! 现在看来应该是这样的,因为真机上 events.count总是为0。 忙活了一下午,看到真机上失败,失望了。 代码如下:让一个1秒的time触发该函数 - (void) getVideoDatas { NSArray *events = mMoviePlayer.accessLog.events; int count = events.count; NSLog(@"events count = %d", count); for (int i = 0; i < count; ++i) { MPMovieAccessLogEvent *currenEvent = [events objectAtIndex:i]; double byts = currenEvent.indicatedBitrate ; int64_t tmp = byts / 8; tmp = tmp / 1024; int64_t byte = currenEvent.numberOfBytesTransferred; int64_t bytes = currenEvent.numberOfBytesTransferred >> 10; NSMutableString *bytesS = [[NSMutableString alloc] initWithCapacity:100]; [bytesS appendFormat"totalSize = %d byte",bytes]; if(bytes > 1024) { bytes = bytes >> 10; [bytesS setString""]; [bytesS appendFormat"totalSize = %d M",bytes]; } NSLog(@"byts = %f, byte = %lld bytes = %lld bits = %lld", byts,byte, bytes, tmp); [bytesS appendFormat" || speed = %d k",tmp]; [mSpeedLabel setText:bytesS]; [bytesS release]; } } |
MPMoviePlayerController and MPMovieAccessLog
最新推荐文章于 2017-07-29 14:28:55 发布