Buffering events

This guide is intended for IMA publishers who want to take action based on ad buffering state.


Using buffer events in your app

As of beta v15, the IMAAdsManagerDelegate adds the following delegate methods related to ad buffering:

  • - (void)adsManagerAdDidStartBuffering(IMAAdsManager *)adsManager
    • Called when an ad that already started playing has stopped to buffer.
  • - (void)adsManager:(IMAAdsManager *)adsManager adDidBufferToMediaTime:(NSTimeInterval)mediaTime
    • Called as an ad buffers. This method is called repeatedly as long as an ad is buffering.
  • - (void)adsManagerAdPlaybackReady:(IMAAdsManager *)adsManager
    • Called when the current ad is sufficiently buffered such that ad playback is not likely to outrun the buffer.

You can use the above methods to add an activity indicator to your app when ads pause to buffer, as in the sample code below. All additions are based on the IMA SDK Advanced Sample:

@interface VideoViewController () <IMAAdsManagerDelegate,...>



@implementation VideoViewController


- (void)adsManagerAdDidStartBuffering:(IMAAdsManager *)adsManager {
  // Show your activity indicator above the video player - ad playback has
  // stopped to buffer.

- (void)adsManagerAdPlaybackReady:(IMAAdsManager *)adsManager {
  // Hide your activity indicator - as playback resumes.


Can I show an activity indicator before my ad starts playing?
Yes you can, but you should rely on different delegate methods for that use case. You can show the activity indicator when you call [adsManager start], and hide the activity indicator when you catch kIMAAdEvent_STARTED in - (void)adsManager:(IMAAdsManager *)adsManager didReceiveAdEvent:(IMAAdEvent *)event.