Skip to main content

Reserved Macros and Macro Usage

LuraPlayer SDK allows parts of strings in ad tag URLs to be dynamically replaced by given or on the fly generated values, which in LuraPlayer is called as macros. Macros can be a powerful tool for creating flexible and customizable ad playbacks, and can help to streamline development and improve overall user experience.

Implementing Macros

In order to add macros, you need to encapsulate your macro string by square brackets in the URLs that you've provided.

url = "https://example.com/adtag?macro1=[MACRO1]&macro2=[MACRO2]";

After specifying the macros, in your URLs, you can specify them using macros attribute.

macros = mapOf(
MACRO1 to "your_custom_macro1",
MACRO2 to "your_custom_macro2",
)

Here is an example code that uses macros in ad tag urls:

val luraConfiguration = LuraConfiguration(
ads = LuraAdsConfiguration(
macros = mapOf(
"USER_ID" to "1234567890",
"SESSION_ID" to "078a54ef-c45e-4356-b556-a99fdab158c1",
),
clientSide = LuraClientSideConfiguration(
provider = "generic",
generic = LuraGenericConfiguration(
breaks = listOf(
LuraGenericBreak(
offset = "start",
url = "https://example.com/adtag?userid=[USER_ID]&session_id=[SESSION_ID]"
),
)
)
)
)
)

playerView = findViewById(R.id.lura_player_view)
player = LuraPlayer(context = this, playerView = playerView)
player.setConfig(luraConfiguration)

In this example code, [USER_ID] occurencies will be replaced by 1234567890 and [SESSION_ID] occurencies will be replaced by 078a54ef-c45e-4356-b556-a99fdab158c1

Reserved Macros

Some macros in LuraPlayer are reserved for custom functionality. Macros that starts with LURA_ are reserved to be used as functional macros. Here are the list of the macros that are reserved:

AttributeDescription
LURA_PAL_NONCENonce generated by PAL SDK if PAL Plugin is configured and enabled
LURA_CORRELATORRandomly generated string

Reserved macros will be filled automatically by LuraPlayer, you don't need to specify them in the macros attribute.

caution

Note that reserved macros might increase in the future. Please note that macros that starts with LURA_ prefix will be ignored.

Here is an example code that includes both custom macros and reserved macros:

val luraConfiguration = LuraConfiguration(
content = LuraContent(
media = listOf(
LuraMedia(
type = "video/x-mpegurl",
url = ""
)
),
id = "id",
title = "title",
type = LuraVideoType.VOD
),
ads = LuraAdsConfiguration(
macros = mapOf(
"MY_MACRO" to "my-url-safe-macro"
),
clientSide = LuraClientSideConfiguration(
provider = "generic",
generic = LuraGenericConfiguration(
breaks = listOf(
LuraGenericBreak(
offset = "start",
url = "https://example.com/adtag?mycustommacro=[MY_MACRO]&correlator=[LURA_CORRELATOR]&givn=[LURA_PAL_NONCE]"
),
)
)
)
),
plugins = LuraPluginsConfigurations(
pal = PalConfiguration(
enabled = true,
allowStorageConsent = true,
ppid = "",
descriptionURL = ""
)
)
)

playerView = findViewById(R.id.lura_player_view)
player = LuraPlayer(context = this, playerView = playerView)
player.setConfig(luraConfiguration)