Skip to main content

AdsBroadpeak library

The fl-ads-broadpeak library integrates Broadpeak SmartLib to provide Server Side Ad Insertion (SSAI) for both VOD and Live content on iOS and Android.

Setup

Add the required Broadpeak dependencies to your project before initializing the library.

Adding dependencies

  1. Add the Broadpeak SmartLib repository to your root build.gradle:

    maven { url 'https://delivery-platform.broadpeak.tv/android/repository/smartlib' }
  2. Add the Broadpeak dependency to your application module build.gradle:

    implementation "tv.broadpeak.smartlib:smartlib-media3:05.04.04.808048b"

Note: Use the Broadpeak and Google PAL library versions shipped with the QuickPlay libraries.


Create Broadpeak session initialization data

The BroadpeakInitializationData object holds global configuration that is passed once when initializing SmartLib.

import {
BroadpeakCDN,
AnalyticsHost,
BroadpeakInitializationData,
} from '@quickplay/rn-qp-nxg-player';

const broadpeakCDN: BroadpeakCDN = {
type: '<cdn type>',
domainHostNames: ['<broadpeak cdn hostname>'], // required when type is 'Custom'
};

const analyticsHostNames: AnalyticsHost = {
type: '<analytics host type>',
hostNames: ['<analytics server url>'], // required when type is 'Custom'
};

const config: BroadpeakInitializationData = {
broadpeakDomainHostNames: broadpeakCDN,
analyticsHostNames: analyticsHostNames,
uuid: '<unique user or account identifier>',
deviceType: '<device type>',
userAgent: '<user agent string>',
gdprPreference: 4, // 1 = GDPR_DELETE | 2 = GDPR_ANONYMIZED | 3 = GDPR_ENCRYPTED | 4 = GDPR_CLEAR
sessionKeepAliveFrequencyMs: 5000,
loggerLevel: -1, // -1 = LOG_OFF | 0 = LOG_BASIC | 1 = LOG_VERBOSE
allowStorage: true,
};
NameTypeDescription
broadpeakDomainHostNamesBroadpeakCDNRequired. The domainHostNames list used to identify Broadpeak sessions. type: 'All' — all sessions use a Broadpeak CDN; type: 'None' — no URLs are on a Broadpeak CDN; type: 'Custom' — only the listed hostnames are Broadpeak CDN.
analyticsHostNamesAnalyticsHostAnalytics server hostnames. type: 'None' disables analytics reporting.
uuidstringA unique user or account identifier used by Broadpeak Analytics.
deviceTypestringOverrides the default device type detected by SmartLib (for example, "phone", "tablet", "tv").
userAgentstringThe user agent string used when firing Broadpeak analytics and ad tracking beacons.
gdprPreferenceBroadpeakGDPRPreferenceGDPR preference for Broadpeak Analytics. GDPR_DELETE — report will be empty; GDPR_ENCRYPTED — decryptable on request; GDPR_ANONYMIZED — no decryption possible; GDPR_CLEAR — no encryption (default).
sessionKeepAliveFrequencyMsnumberOverrides the default SmartLib keep-alive frequency (default: 5000 ms). Valid range: 5000–10000 ms.
loggerLevelBroadpeakLoggerLevelOrdinalLogger verbosity. LOG_BASIC — basic logging; LOG_VERBOSE — verbose logging; LOG_OFF — disable logging.
allowStoragebooleanWhether SmartLib is allowed to persist data to local storage

Per-session configuration (BroadpeakSessionConfig)

BroadpeakSessionConfig is passed per-playback session inside PlayerConfig via broadpeakSessionConfig. It's optional.

import { BroadpeakSessionConfig } from '@quickplay/rn-qp-nxg-player';

const broadpeakSessionConfig: BroadpeakSessionConfig = {
pipSession: true,
customParams: {
'<key>': '<value>',
},
adParams: {
'<key>': '<value>',
},
};
NameTypeDescription
pipSessionbooleanSet to true if the session needs to support Picture-in-Picture.
customParams{ [key: string]: string }Custom key-value pairs sent to Broadpeak Analytics.
adParams{ [key: string]: string }Custom key-value pairs forwarded to Broadpeak ad requests.

Initialize Broadpeak SmartLib

This must be done once, when the app starts (e.g. in your root component or app entry point). Sets isInitialized to true; after this call isConfigured() returns true. component or app entry point:

await broadpeakSessionManager.initWithConfig(config);

Check if Broadpeak SmartLib is initialized

Returns the value of the internal isInitialized flag — true if initWithConfig() has been called successfully, false otherwise.

const configured: boolean = await broadpeakSessionManager.isConfigured();

Release Broadpeak SmartLib

Call this when the app is closing (Android only not implemented in iOS ). Clears isInitialized on Android so isConfigured() returns false; on iOS this is a no-op.

await broadpeakSessionManager.dispose();

Note: initWithConfig() must be paired with dispose() on Android.


Create an ad player

  • Requires isInitialized to be true (i.e., isConfigured() must return true) before creating a Broadpeak SSAI player.
  • Configure and create a player with Broadpeak SSAI by setting isSSAIEnabled to true and ssaiAdProvider to 'broadpeak' in PlayerConfig:
const playerConfig: PlayerConfig = {
contentType: '<content type>',
isSSAIEnabled: true, // mandatory for Broadpeak
ssaiAdProvider: 'broadpeak', // mandatory for Broadpeak
mediaURL: '<content url>',
mediaType: '<media type>', // required for live content
palConfiguration: { // required when using Broadpeak SSAI with Google PAL
descriptionURL: '<content or page url>',
omidPartnerName: '<omid partner name>',
omidPartnerVersion: '<omid partner version>',
omidVersion: '<omid version>',
playerType: '<player type>',
playerVersion: '<player version>',
ppid: '<publisher provided id>',
videoPlayerHeight: 720,
videoPlayerWidth: 1280,
},
broadpeakSessionConfig: {
pipSession: false,
customParams: { '<key>': '<value>' },
},
};

const broadpeakAdPlayer = await createPlayer(playerConfig);

// Attach player listeners before calling play.
broadpeakAdPlayer.play();
NameTypeDescription
mediaURLstringRequired. The playback URL.
contentTypeConsumptionTypeValueRequired. 'VOD' or 'LIVE'.
isSSAIEnabledbooleanRequired. Must be true for SSAI/Broadpeak playback.
ssaiAdProviderssaiAdProviderRequired. Must be 'broadpeak'.
mediaTypeMediaTypeRequired. 'HLS' or 'DASH'.
palConfigurationPALConfigurationPer-session PAL config. Required when using Broadpeak SSAI with Google PAL.
broadpeakSessionConfigBroadpeakSessionConfigPer-session Broadpeak config (PiP, custom params, ad params).
adPlaybackPolicyAdPlaybackPolicyDefines ad playback policy for VOD content.

Example Integration

The following example shows a complete integration using all Broadpeak APIs — checking isConfigured(), initialising SmartLib via initWithConfig(), creating a Broadpeak SSAI player with broadpeakSessionConfig, and releasing SmartLib via dispose() on teardown.

import {
broadpeakSessionManager,
createPlayer,
BroadpeakCDN,
AnalyticsHost,
BroadpeakInitializationData,
PlayerConfig,
} from '@quickplay/rn-qp-nxg-player';

// 1. Check isConfigured() — returns the isInitialized flag value.
// Only call initWithConfig() when SmartLib is not yet initialized.
const configured = await broadpeakSessionManager.isConfigured();

if (!configured) {
const broadpeakCDN: BroadpeakCDN = {
type: 'Custom',
domainHostNames: ['ucdn.mediaquest.com.ph'],
};
const analyticsHostNames: AnalyticsHost = {
type: 'None',
};
const config: BroadpeakInitializationData = {
broadpeakDomainHostNames: broadpeakCDN,
analyticsHostNames,
uuid: '',
deviceType: '',
userAgent: '',
gdprPreference: 2, // GDPR_ANONYMIZED
sessionKeepAliveFrequencyMs: 5000,
loggerLevel: 0, // LOG_BASIC
allowStorage: true,
};

// 2. initWithConfig() — sets isInitialized to true; isConfigured() returns true after this.
await broadpeakSessionManager.initWithConfig(config);
}

// 3. createPlayer() — requires isInitialized = true (isConfigured() must return true).
const playerConfig: PlayerConfig = {
contentType: 'LIVE',
isSSAIEnabled: true,
ssaiAdProvider: 'broadpeak',
mediaURL: 'https://ucdn.mediaquest.com.ph/bpk-tv/ssai_test/default/index.m3u8',
mediaType: 'HLS',
broadpeakSessionConfig: {
pipSession: true,
customParams: { key1: 'value1' },
adParams: { adKey: 'adValue' },
},
};

const player = await createPlayer(playerConfig);

// add required listeners.

player.play();