4

Is there a way to detect how much data has been buffered while streaming video in MPMoviePlayerController?

I've already checked loadState but that does not give me enough info about buffering.

Youtube's app has exactly what I want...

Borut Tomazin
  • 8,041
  • 11
  • 78
  • 91
  • 1
    you should refere similar post http://stackoverflow.com/questions/10346327/mpmovieplayercontroller-when-will-i-know-that-the-downloading-of-the-file-reach – Maulik Dec 28 '12 at 07:39

1 Answers1

7

You can try to get movie access log during playing video.

- (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);
    }
}

Then you can call the above by such as,

[NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(calculateBufferSize) userInfo:nil repeats:YES];

after

[self.moviePlayerController play];

https://developer.apple.com/library/ios/#DOCUMENTATION/MediaPlayer/Reference/MPMovieAccessLog_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40010561

Jingwei
  • 745
  • 9
  • 22
  • 1
    Thanks but I've already get proper nicer solution: http://stackoverflow.com/questions/10346327/mpmovieplayercontroller-when-will-i-know-that-the-downloading-of-the-file-reach – Borut Tomazin Jan 24 '13 at 12:58