在AVFoundation Framework for iPhone中获取下载视频的接收字节数

时间:2013-01-03 06:49:22

标签: iphone objective-c avfoundation avplayer

您好我正在使用AVFoundation Framework来播放来自互联网的剪辑。我使用AVPlayerItem playerItemWithURL:URL

现在我想检查该视频文件中接收字节的大小。我在这个页面上找不到任何相关内容: https://developer.apple.com/library/mac/#documentation/AVFoundation/Reference/AVPlayerItem_Class/Reference/Reference.html

那么有没有办法找到收到的字节大小?

1 个答案:

答案 0 :(得分:4)

看看AVPlayerItemAccessLogEvent班级。

您可以通过`

访问
self.aPlayer.currentItem.accessLog
AVPlayerItemAccessLog *accesslog = self.aPlayer.currentItem.accessLog;  
NSArray *events = [accesslog events];    
AVPlayerItemAccessLogEvent *event = [events objectAtIndex:0]; 
NSLog(@"Number of bytes received %@", [event numberOfBytesTransferred]);

您有Accesslog,它会为您提供详细信息 数据属性

  numberOfSegmentsDownloaded  property
  numberOfMediaRequests  property
  playbackStartDate  property
  URI  property
  serverAddress  property
  numberOfServerAddressChanges  property
  playbackSessionID  property
  playbackStartOffset  property
  segmentsDownloadedDuration  property
  durationWatched  property
  numberOfStalls  property
  numberOfBytesTransferred  property
  indicatedBitrate  property
  observedBitrate  property
  numberOfDroppedVideoFrames  property

IMO,这是你唯一的选择,但这也有其缺陷,特别是在寻求等方面。