开发者

Determening MPMovieController bit-rate

Is there a way to determine t开发者_C百科he bit-rate of the stream an MPMovieController is playing? I am programming in objective-c on iOS


You can get the indicated bit rate from event, which is the bit rate of the stream according to the m3u8. To calculate the actual bit rate I divide event.numberOfBytesTransferred / event.durationWatched and multiply by 8.

NSArray *events = self.player.accessLog.events;
    MPMovieAccessLogEvent *event = (MPMovieAccessLogEvent *)[events lastObject];
double calculatedBitRate = 8 * event.numberOfBytesTransferred / event.durationWatched;
    value = [nf stringFromNumber:[NSNumber numberWithDouble:calculatedBitRate]];
    self.calculatedBitRateLabel.text = [NSString stringWithFormat:@"My calculated bit rate = %@", value];


Found it, the "accessLog" gives you periodic stats which include the observed bitrate:

MPMovieAccessLogEvent *evt=nil;
MPMovieAccessLog *accessL=[moviePlayer accessLog];
NSArray *events = accessL.events;
for (int i=0; i<[events count]; i++) {
    evt=[events objectAtIndex:i];
}
return evt.observedBitrate
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜