SVSAdManagerDelegate

Objective-C

@protocol SVSAdManagerDelegate <NSObject>

Swift

protocol SVSAdManagerDelegate

Delegate protocol for SVSAdManager instances.

Use it if you want more information about the ad break that is being played, about errors or about user interactions.

Manager Start Informations

  • Called when an ad manager instance fails to start. This can occur for several reasons such as contentPlayhead not ready, etc. See error for more informations.

    Declaration

    Objective-C

    - (void)adManager:(nonnull SVSAdManager *)adManager
        didFailToStartWithError:(nonnull NSError *)error;

    Swift

    func adManager(_ adManager: Any!, didFailToStartWithError error: Any!)

    Parameters

    adManager

    The SVSAdManager instance that failed to start.

    error

    A NSError instance corresponding to the error.

Ad Break Informations

  • Called when an ad manager instance fails to play an ad break.

    Declaration

    Objective-C

    - (void)adManager:(nonnull SVSAdManager *)adManager
        didFailToStartAdBreak:(SVSAdBreakType)adBreakType
                        error:(nonnull NSError *)error;

    Swift

    func adManager(_ adManager: Any!, didFailToStartAdBreak adBreakType: Any!, error: Any!)

    Parameters

    adManager

    The SVSAdManager instance that failed to start an AdBreak.

    adBreakType

    The ad break type (overlay, preroll, midroll, postroll).

    error

    A NSError instance corresponding to the error.

  • Called when an ad manager instance starts to play an ad break.

    Declaration

    Objective-C

    - (void)adManager:(nonnull SVSAdManager *)adManager
        didStartAdBreak:(SVSAdBreakType)adBreakType;

    Swift

    func adManager(_ adManager: Any!, didStartAdBreak adBreakType: Any!)

    Parameters

    adManager

    The SVSAdManager instance that started.

    adBreakType

    The ad break type (overlay, preroll, midroll, postroll).

  • Called when an ad manager instance is finishing to play an ad break.

    Declaration

    Objective-C

    - (void)adManager:(nonnull SVSAdManager *)adManager
        didFinishAdBreak:(SVSAdBreakType)adBreakType
             numberOfAds:(NSInteger)numberOfAdsPlayed
                duration:(NSTimeInterval)duration
                   error:(nullable NSError *)error;

    Swift

    func adManager(_ adManager: Any!, didFinishAdBreak adBreakType: Any!, numberOfAds numberOfAdsPlayed: Any!, duration: Any!, error: Any!)

    Parameters

    adManager

    The SVSAdManager instance that finished an ad break.

    adBreakType

    The ad break type (overlay, preroll, midroll, postroll).

    numberOfAdsPlayed

    The number of ads played during this ad break.

    duration

    The total duration of the ad break.

    error

    A NSError instance if an error happens, nil otherwise.

  • Called when an ad manager instance did generate cue points. Can be useful to setup your player.

    Declaration

    Objective-C

    - (void)adManager:(nonnull SVSAdManager *)adManager
        didGenerateCuePoints:(nonnull NSArray<SVSCuePoint *> *)cuePoints;

    Swift

    func adManager(_ adManager: Any!, didGenerateCuePoints cuePoints: Any!)

    Parameters

    adManager

    The SVSAdManager instance that finished an ad break.

    cuePoints

    A NSArray containing SVSCuePoint instances. Each SCSVideoCuePoint instance represent the position of an adbreak.

Playback

  • Called when an ad manager instance will start to play ads. You should pause your content player in this method.

    Declaration

    Objective-C

    - (void)adManagerDidRequestToPauseContentPlayer:
                (nonnull SVSAdManager *)adManager
                                         forAdBreak:(SVSAdBreakType)adBreakType;

    Swift

    func adManagerDidRequest(toPauseContentPlayer adManager: Any!, forAdBreak adBreakType: Any!)

    Parameters

    adManager

    The SVSAdManager instance about to play an ad.

    adBreakType

    The ad break type (overlay, preroll, midroll, postroll).

  • Called when an ad manager instance finished to play ads. You should resume your content player in this method.

    Declaration

    Objective-C

    - (void)adManagerDidRequestToResumeContentPlayer:
                (nonnull SVSAdManager *)adManager
                                        afterAdBreak:(SVSAdBreakType)adBreakType;

    Swift

    func adManagerDidRequest(toResumeContentPlayer adManager: Any!, afterAdBreak adBreakType: Any!)

    Parameters

    adManager

    The SVSAdManager instance which finished to play ads.

    adBreakType

    The ad break type (overlay, preroll, midroll, postroll).

  • Called periodically to keep track of the ad manager’s playback status.

    Implement this method for custom tracking, trigger background tasks, etc…

    Declaration

    Objective-C

    - (void)adManager:(nonnull SVSAdManager *)adManager
        didProgressToTime:(NSTimeInterval)currentTime
                totalTime:(NSTimeInterval)totalTime;

    Swift

    func adManager(_ adManager: Any!, didProgressToTime currentTime: Any!, totalTime: Any!)

    Parameters

    adManager

    The SVSAdManager instance currently playing.

    currentTime

    The current time of the player.

    totalTime

    The total duration of the player’s playlist.

Fullscreen

  • Called when the enter fullscreen button of an Ad is clicked by the user. Adapt your UI to properly react to this user action: you should resize your container view so it fits the whole screen.

    Declaration

    Objective-C

    - (void)adManagerDidRequestToEnterFullscreen:(nonnull SVSAdManager *)adManager;

    Swift

    func adManagerDidRequest(toEnterFullscreen adManager: Any!)

    Parameters

    adManager

    The SVSAdManager instance asking to enter fullscreen.

  • Called when the exit fullscreen button of an Ad is clicked by the user. Adapt your UI to properly react to this user action: you should resize your container view so it goes back to its original size.

    Declaration

    Objective-C

    - (void)adManagerDidRequestToExitFullscreen:(nonnull SVSAdManager *)adManager;

    Swift

    func adManagerDidRequest(toExitFullscreen adManager: Any!)

    Parameters

    adManager

    The SVSAdManager instance asking to exit fullscreen.

Modal Presentation

  • Called when the ad has been clicked and needs to open a modal.

    Implement this method and return the appropriate UIViewController to present the post click modal controller.

    Declaration

    Objective-C

    - (nonnull UIViewController *)
        adManagerDidRequestPostClickPresentationViewController:
            (nonnull SVSAdManager *)adManager;

    Swift

    func adManagerDidRequestPostClickPresentationViewController(_ adManager: Any!) -> Any!

    Parameters

    adManager

    The SVSAdManager instance that needs the current UIViewController.

    Return Value

    An UIViewController from which the post click modal controller should be presented.

Optional

  • Called when the ad break is ready to start.

    This method will be called only if the ‘enableAdBreakAutoplay’ option is disabled. Added to let you start the adBreak when you want, more information in the official documentation.

    Warning: Do not forget to call [SVSAdManager startAdBreak] when this delegate method is called!

    Declaration

    Objective-C

    - (void)adManager:(nonnull SVSAdManager *)adManager
        isReadyToStartAdBreak:(SVSAdBreakType)adBreakType;

    Swift

    optional func adManager(_ adManager: Any!, isReadyToStartAdBreak adBreakType: Any!)

    Parameters

    adManager

    The SVSAdManager instance ready to start the ad break.

    adBreakType

    The ad break type (overlay, preroll, midroll, postroll).