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.
- Android
- iOS
Adding dependencies
-
Add the Broadpeak SmartLib repository to your root
build.gradle:maven { url 'https://delivery-platform.broadpeak.tv/android/repository/smartlib' } -
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.
Adding dependencies
-
Add the Broadpeak pod source at the top of your
Podfile, before any other source declarations:source 'https://delivery-platform.broadpeak.tv/ios/broadpeak/specs.git'source 'https://cdn.cocoapods.org/' -
Run
pod installafter updating sources.
Known iOS integration issues
The following issues occur when integrating SmartLib on iOS. Apply the
workarounds inside the post_install block of your Podfile.
Issue 1: AdType enum collision between ConvivaSDK and SmartLib
Both ConvivaSDK and SmartLib define an AdType enum with different values.
This causes a Clang module consistency error at compile time:
error: 'AdType' redeclared with a different underlying type
Workaround: In post_install, patch ConvivaSDK's CISConstants.h to
rename AdType to ConvivaAdType:
post_install do |installer|
installer.pods_project.build_configurations.each do |config|
config.build_settings["CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES"] = true
end
Dir.glob("#{installer.sandbox.root}/ConvivaSDK/**/CISConstants.h").each do |path|
content = File.read(path)
next if content.include?('ConvivaAdType')
patched = content.gsub(/\bAdType\b/, 'ConvivaAdType')
File.write(path, patched) if patched != content
end
end
Issue 2: Nested OMSDK_Broadpeaktv.framework not loadable at runtime
OMSDK_Broadpeaktv.framework is shipped nested inside
SmartLibOMSDK.framework/Frameworks/. iOS doesn't support nested dynamic
frameworks — dyld only searches the app's top-level Frameworks/ folder, so
the nested framework isn't found at runtime and the app crashes:
dyld: Library not loaded: @rpath/OMSDK_Broadpeaktv.framework/OMSDK_Broadpeaktv
Workaround: Inject a Run Script build phase into the main app target via
post_install to copy and re-sign the framework at build time:
OMSDK_SCRIPT_NAME = 'Copy and Sign OMSDK_Broadpeaktv'
OMSDK_SHELL_SCRIPT = <<~SHELL
NESTED="${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/SmartLibOMSDK.framework/Frameworks/OMSDK_Broadpeaktv.framework"
DEST="${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/OMSDK_Broadpeaktv.framework"
if [ -d "${NESTED}" ]; then
rm -rf "${DEST}"
cp -R "${NESTED}" "${DEST}"
codesign --force --sign "${EXPANDED_CODE_SIGN_IDENTITY}" \
--preserve-metadata=identifier,entitlements \
"${DEST}"
fi
SHELL
post_install do |installer|
installer.aggregate_targets.each do |aggregate_target|
next unless aggregate_target.name == 'Pods-<YourAppTarget>'
user_project = aggregate_target.user_project
user_project.targets.each do |target|
next unless target.name == '<YourAppTarget>'
next if target.shell_script_build_phases.any? { |p| p.name == OMSDK_SCRIPT_NAME }
phase = target.new_shell_script_build_phase(OMSDK_SCRIPT_NAME)
phase.shell_script = OMSDK_SHELL_SCRIPT
end
user_project.save
end
end
Note: Replace
<YourAppTarget>with your actual Xcode target name (for example,QuickplayRN).
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,
};
| Name | Type | Description |
|---|---|---|
| broadpeakDomainHostNames | BroadpeakCDN | Required. 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. |
| analyticsHostNames | AnalyticsHost | Analytics server hostnames. type: 'None' disables analytics reporting. |
| uuid | string | A unique user or account identifier used by Broadpeak Analytics. |
| deviceType | string | Overrides the default device type detected by SmartLib (for example, "phone", "tablet", "tv"). |
| userAgent | string | The user agent string used when firing Broadpeak analytics and ad tracking beacons. |
| gdprPreference | BroadpeakGDPRPreference | GDPR 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). |
| sessionKeepAliveFrequencyMs | number | Overrides the default SmartLib keep-alive frequency (default: 5000 ms). Valid range: 5000–10000 ms. |
| loggerLevel | BroadpeakLoggerLevelOrdinal | Logger verbosity. LOG_BASIC — basic logging; LOG_VERBOSE — verbose logging; LOG_OFF — disable logging. |
| allowStorage | boolean | Whether 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>',
},
};
| Name | Type | Description |
|---|---|---|
| pipSession | boolean | Set 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 withdispose()on Android.
Create an ad player
- Requires
isInitializedto betrue(i.e.,isConfigured()must returntrue) before creating a Broadpeak SSAI player. - Configure and create a player with Broadpeak SSAI by setting
isSSAIEnabledtotrueandssaiAdProviderto'broadpeak'inPlayerConfig:
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();
| Name | Type | Description |
|---|---|---|
| mediaURL | string | Required. The playback URL. |
| contentType | ConsumptionTypeValue | Required. 'VOD' or 'LIVE'. |
| isSSAIEnabled | boolean | Required. Must be true for SSAI/Broadpeak playback. |
| ssaiAdProvider | ssaiAdProvider | Required. Must be 'broadpeak'. |
| mediaType | MediaType | Required. 'HLS' or 'DASH'. |
| palConfiguration | PALConfiguration | Per-session PAL config. Required when using Broadpeak SSAI with Google PAL. |
| broadpeakSessionConfig | BroadpeakSessionConfig | Per-session Broadpeak config (PiP, custom params, ad params). |
| adPlaybackPolicy | AdPlaybackPolicy | Defines 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();