SVSAdManager

Objective-C

@interface SVSAdManager : NSObject

Swift

class SVSAdManager : NSObject

The ad manager is the class responsible of loading ads and displaying them into the ad player.

This class is instantiated with a placement, a set of ad rules, an ad player configuration and is started with a play head object (a protocol representing the state of the content player) and an ad container view which is the view that will be used as superview by the ad player view.

Initialization

Playback lifecycle

  • Starts the ad manager.

    This will allow the ad manager to load and display ads for the content described by the play head protocol.

    Declaration

    Objective-C

    - (void)startWithPlayHead:(nonnull id<SVSContentPlayerPlayHead>)playHead
              adContainerView:(nonnull UIView *)adContainerView;

    Swift

    func start(with playHead: any SVSContentPlayerPlayHead, adContainerView: UIView)

    Parameters

    playHead

    A protocol representing the state of the content player.

    adContainerView

    The container view in which the ad player view will be displayed.

  • Will start the waiting ad break, if any. To use only if you have disable the adbreak autoplay. Warnings: if you do not call this method, the ad break will never start and the SDK will be paused waiting for this method call. More information in the official documentation.

    Declaration

    Objective-C

    - (void)startAdBreak;

    Swift

    func startAdBreak()
  • Stops the ad manager. Use this method only if your content is stopped by an user action such as clicking on a STOP button on your content player UI. Calling this method can trigger a PostRoll advertisement if defined in your AdRules. Calling this method has no effect if an Ad break is already being played.

    If the content finishes without being interrupted by an user interaction, the Ad Manager will automatically trigger the appropriate PostRoll advertisement based on the content player current time, it is not necessary to call this method.

    Declaration

    Objective-C

    - (void)stopAndTriggerPostrollIfAny:(BOOL)triggerPostroll;

    Swift

    func stopAndTriggerPostrollIfAny(_ triggerPostroll: Bool)

    Parameters

    triggerPostroll

    Whether or not the Ad Manager should trigger a postroll ad if any in your SVSAdRule.

  • Tells the ad manager that your content is being replayed (after being completed). You should make sure your content player seeks to the begining of the content video before calling this method.

    This will reset the status of PreRoll and PostRoll advertisements so they can be served again if your AdPlayerConfiguration.publisherOptions.replayAds is YES.

    Note

    This method has no impact on MidRoll advertisements. They will continue playing according to the appropriate AdRule and playHead status.

    Declaration

    Objective-C

    - (void)replay;

    Swift

    func replay()

Fullscreen management

  • Tells the ad manager that your content player entered / exited fullscreen mode.

    The AdPlayer view will always stick to your container view even when you resize or rotate it. However, the AdManager needs to know about your fullscreen status to keep the Fullscreen button status up to date when playing Ad breaks. This is particularly important if your application responds to orientation changes by entering / exiting fullscreen.

    Declaration

    Objective-C

    - (void)contentPlayerIsFullscreen:(BOOL)isFullscreen;

    Swift

    func contentPlayerIsFullscreen(_ isFullscreen: Bool)

    Parameters

    isFullscreen

    Whether or not the content player is in fullscreen mode.

Properties

  • The delegate of the ad manager.

    Declaration

    Objective-C

    @property (nonatomic, weak) id<SVSAdManagerDelegate> _Nullable delegate;

    Swift

    weak var delegate: (any SVSAdManagerDelegate)? { get set }
  • Tells whether or not the SVSAdManager is started. Use this method in your integration to know if you already started your SVSAdManager instance or not.

    Declaration

    Objective-C

    - (BOOL)isStarted;

    Swift

    func isStarted() -> Bool

    Return Value

    whether or not the SVSAdManager instance has been started.