Observing Player Events

As the player is playing its content, the AdPlayerTag emits relevant events describing the process.

To receive the events you should assign an observer that confirms to the AdPlayerTagEventsObserver protocol by one of the following methods:

Add an observer as part of the tag initialization process

// ViewController.swift var tag = AdPlayerTagConfiguration(tagId: tagId) tag.eventsObserver = self

Or add an observer to an instance of AdPlayerTag after obtaining it using method 2 of the previous section

// ViewController.swift tag.eventsObserver = self

You’ll need to conform AdPlayerTagEventsObserver protocol

extension ViewController: AdPlayerTagEventsObserver { func onAdPlayerEvent(_ event: AdPlayerSDK.AdPlayerEvent) { print(event) } }

 

The emitted events are:

Event class

Event type

Description

Event class

Event type

Description

AdPlayerEventGeneric

AdPlayerEventType.fullScreenRequested

Called when the user requested full screen.

AdPlayerEventGeneric

AdPlayerEventType.inventory

Called when the player is initialized.

AdPlayerEventGeneric

AdPlayerEventType.adLoaded

Indicates the first time an ad sources triggered the AdLoaded event.

AdPlayerEventGeneric

AdPlayerEventType.adImpression

Called when there is a video impression.

AdPlayerEventGeneric

AdPlayerEventType.adVideoFirstQuartile

Called when the ad reached 25% of the ad video.

AdPlayerEventGeneric

AdPlayerEventType.adVideoMidpoint

Called when the ad reached 50% of the ad video.

AdPlayerEventGeneric

AdPlayerEventType.adVideoThirdQuartile

Called when the ad reached 75% of the ad video.

AdPlayerEventGeneric

AdPlayerEventType.adVideoCompleted

Called when the ad is completed.

AdPlayerEventGeneric

AdPlayerEventType.adClickThrough

Called when the ad is clicked on.

AdPlayerEventGeneric

AdPlayerEventType.adSkipped

Called when an ad is skipped.

AdPlayerEventGeneric

AdPlayerEventType.adSkippableStateChanged

Called when the ad skip button becomes available.

AdPlayerEventGeneric

AdPlayerEventType.closed

Called when the close button is clicked.

AdPlayerEventGeneric

AdPlayerEventType.adPaused

Called when the ad is paused.

AdPlayerEventGeneric

AdPlayerEventType.adPlaying

Called when the ad starts playing or resumed.

AdPlayerEventGeneric

AdPlayerEventType.contentPaused

Called when the content video is paused.

AdPlayerEventGeneric

AdPlayerEventType.contentPlaying

Called when the content video resume playing.

AdPlayerEventVolume

AdPlayerEventType.adVolumeChange

Called when the ad volume is changed. Contains the new volume level in the AdPlayerEventVolume.volume parameter. Casting is required to access the parameter.

AdPlayerEventVolume

AdPlayerEventType.contentVolumeChange

Called when the content volume is changed. Contains the new volume level in the AdPlayerEventVolume.volume parameter. Casting is required to access the parameter.

AdPlayerEventGeneric

AdPlayerEventType.contentVideoStart

Content started playing.

AdPlayerEventGeneric

AdPlayerEventType.contentVideoFirstQuartile

Called when the content reached 25%.

AdPlayerEventGeneric

AdPlayerEventType.contentVideoMidpoint

Called when the content reached 50%.

AdPlayerEventGeneric

AdPlayerEventType.contentVideoThirdQuartile

Called when the content reached 75%.

AdPlayerEventGeneric

AdPlayerEventType.contentVideoComplete

Called when the content is completed.

AdPlayerEventError

AdPlayerEventType.adError

Called by the player every time it finish running 1 + vastRetry waterfall runs without impression. An (optional) error message can be found at AdPlayerEventError.message. Casting is required to access the parameter.

AdPlayerEventGeneric

AdPlayerEventType.adErrorLimit

Called also whenever the player decides that it should stop running, for example when maxImp or maxRun is reached, to indicate the player is stopping calls for ads.

AdPlayerEventError

AdPlayerEventType.error

An error has occurred. An (optional) error message can be found at AdPlayerEventError.message. Casting is required to access the parameter.