Configuration options for HLS interstitials handling

interface InterstitialsConfig {
    customAttributesMapping?: ((mappingData, mappingRegistry) => void);
    customAttributesMappingPreset?: CustomAttributesMappingPresets;
    shouldLoadInterstitial?: ((interstitial) => boolean);
    shouldPlayInterstitial?: ((interstitial) => boolean);
    shouldPlayJumpedOverInterstitials?: ((interstitials, fromTime, toTime) => HlsInterstitial[]);
}

Properties

customAttributesMapping?: ((mappingData, mappingRegistry) => void)

Custom attributes mapping callback to map tracking payload data to interstitial tracking registry

Type declaration

    • (mappingData, mappingRegistry): void
    • Parameters

      • mappingData: InterstitialData | InterstitialAssetListData | InterstitialAssetData

        Parsed tracking data present in the interstitial tags

      • mappingRegistry: InterstitialCustomAttributesMappingRegistry

        Registry to register tracking events

        Example:

        const playerConfig = {
        hls: {
        interstitials: {
        customAttributesMapping(mappingData, mappingRegistry) {
        const adCreativeSignaling = mappingData.customAttributes['X-AD-CREATIVE-SIGNALING'];
        const payload = adCreativeSignaling.payload;

        if (!payload) {
        return;
        }

        const firstPayload = payload[0];
        const clickThroughUrl = firstPayload.clickThrough;
        if (clickThroughUrl) {
        mappingRegistry.clickThroughUrl = clickThroughUrl;
        }

        const trackingData = firstPayload.tracking;
        if (trackingData) {
        for (const trackingEvent of trackingData) {
        const eventType = trackingEvent.type;
        const urls = trackingEvent.urls;
        const offset = trackingEvent.offset;

        if (!eventType || !urls) {
        continue;
        }

        switch (eventType) {
        case InterstitialTrackingEventTrigger.IMPRESSION:
        mappingRegistry.tracking.register(
        InterstitialTrackingEventTrigger.IMPRESSION,
        { urls, offset },
        );
        break;
        }
        }
        }
        },
        },
        },
        };

      Returns void

customAttributesMappingPreset?: CustomAttributesMappingPresets

Preset for standard custom attributes mapping When set, the player will automatically map standard custom attributes based on the selected preset.

Default is CustomAttributesMappingPresets.NONE

When InterstitialsConfig.customAttributesMapping is set, this property is ignored. When set to CustomAttributesMappingPresets.AD_CREATIVE_SIGNALING, SVTA "X-AD-CREATIVE-SIGNALING" mapping is applied.

shouldLoadInterstitial?: ((interstitial) => boolean)

Callback to determine if an interstitial ASSET-LIST should be loaded. The callback will be called for every interstitial ASSET-LIST before loading.

Type declaration

    • (interstitial): boolean
    • Parameters

      Returns boolean

Returns

Whether the interstitial should be loaded

Example:

const playerConfig = {
hls: {
interstitials: {
shouldLoadInterstitial: (interstitial) => {
// Only load interstitials with a specific id
return interstitial.id === 'pre-roll-1';
},
},
},
};
shouldPlayInterstitial?: ((interstitial) => boolean)

Callback to determine if an interstitial should be played. The callback will be called for every interstitial before playback.

Type declaration

    • (interstitial): boolean
    • Parameters

      Returns boolean

Returns

Whether the interstitial should be played

Example:

const playerConfig = {
hls: {
interstitials: {
shouldPlayInterstitial: (interstitial) => {
// Only play interstitials with a specific id
return interstitial.id === 'pre-roll-1';
},
},
},
};
shouldPlayJumpedOverInterstitials?: ((interstitials, fromTime, toTime) => HlsInterstitial[])

Callback to determine which interstitials should be played when multiple interstitials are skipped using jump

Type declaration

    • (interstitials, fromTime, toTime): HlsInterstitial[]
    • Parameters

      • interstitials: HlsInterstitial[]

        A list of interstitials to be evaluated

      • fromTime: number

        The start time of the jump operation in seconds

      • toTime: number

        The end time of the jump operation in seconds

      Returns HlsInterstitial[]

Returns

A filtered list of interstitials that should be played

Example:

const playerConfig = {
hls: {
interstitials: {
shouldPlayJumpedOverInterstitials: (interstitials, fromTime, toTime) => {
// Play only interstitials with duration greater than 15 seconds
return interstitials.filter(interstitial => interstitial.duration > 15);
},
},
},
};