Media
Reference guide for Media class and methods provided by Tealium for Android (Kotlin).
Class: Media
The Media
class provides methods for tracking streaming media in apps through the use of custom events. Learn more about media tracking.
The following summarizes the commonly used methods of the Media
class for Tealium Kotlin.
Method | Description |
---|---|
clickAd() |
The user clicked on a ad that is currently playing. |
custom() |
Sends a custom event status to the data layer. |
endAd() |
The ad ended. |
endAdBreak() |
The ad break ended. |
endBuffer() |
The buffer ended. |
endChapter() |
The chapter ended. |
endSeek() |
The user ended seeking. |
endSession() |
The session ended, including ads and content. |
pause() |
The user paused the media. |
ping() |
Sends an interval event to the data layer. |
play() |
The media content started playing. |
resumeSession() |
The session resumed. |
sendMilestone() |
Sends milestone data to the data layer. |
sendSummary() |
Sends summary data to the data layer. |
skipAd() |
The user skipped the current ad. |
skipChapter() |
The user skipped the chapter. |
startAdBreak() |
The ad break started. |
startAd() |
The ad started. |
startBuffer() |
The buffer started. |
startChapter() |
The chapter started. |
startSeek() |
The user started seeking. |
startSession() |
The session started. |
updatePlayerState() |
The start or end of the player state. |
updateQOE() |
Sets the quality of experience bitrate value. |
clickAd()
The user clicked on a ad that is currently playing.
tealium?.media?.clickAd(event)
custom()
Sends a custom event status to the data layer.
tealium?.media?.custom(name)
Parameter | Type | Description |
---|---|---|
name |
String |
The custom event name. |
endAd()
The ad ended.
tealium?.media?.endAd()
endAdBreak()
Ends latest ad break for the current session. Only valid in a current ad break.
tealium?.media?.endAdBreak()
endBuffer()
The buffer ended.
tealium?.media?.endBuffer()
endChapter()
The chapter ended.
tealium?.media?.endChapter()
endSeek()
The user ended seeking. Records seek ended at given position.
tealium?.media?.endSeek(position)
Parameter | Type | Description |
---|---|---|
position |
Int |
The index position in the media, in seconds, where seek ended. |
Example:
tealium?.media?.startSeek(10)
endSession()
The session ended, including ads and content.
tealium?.media?.endSession()
pause()
The user paused the media.
tealium?.media?.pause()
ping()
Sends an interval event to the data layer. This method is called automatically every 10 seconds if the tracking type for the MediaContent
object is set to INTERVAL
or INTERVAL_MILESTONE
.
tealium?.media?.ping()
Learn more about media tracking types.
play()
The media content started playing.
tealium?.media?.play()
resumeSession()
The session resumed.
tealium?.media?.startSession()
sendMilestone()
Sends a milestone event to the data layer. This method is called automatically, based on the The percent of content played, the tracking type for the MediaContent
object is set to MILESTONE
or INTERVAL_MILESTONE
.
tealium?.media?.sendMilestone()
Milestone values:
Media % Played | Milestone Value |
---|---|
8.0 - 12.0 | 10% |
23.0 - 27.0 | 25% |
48.0 - 52.0 | 50% |
73.0 - 77.0 | 75% |
88.0 - 92.0 | 90% |
97.0 - 100.0 | 100% |
Learn more about media tracking types.
sendSummary()
Sends summary data to the data layer. This method is called automatically on endSession()
if the tracking type for the MediaContent
object is set to SUMMARY
.
tealium?.media?.sendSummary()
Learn more about media tracking types.
skipAd()
The user skipped the current ad.
tealium?.media?.skipAd()
skipChapter()
The user skipped the chapter.
tealium?.media?.skipChapter()
startAd()
The ad started. Call the endAd()
method when the ad completes.
tealium?.media?.startAd(ad)
Parameter | Type | Description |
---|---|---|
ad |
Ad |
The ad object. |
Example:
tealium?.media?.startAd(Ad("Ad 1"))
startAdBreak()
The ad break started. Call the endAdBreak()
method when the ad break completes.
tealium?.media?.startAdBreak(break)
Parameter | Type | Description |
---|---|---|
break |
AdBreak |
The ad break object. |
Example:
val adBreak = AdBreak(name = "Ad Break 1")
tealium?.media?.startAdBreak(adBreak)
startBuffer()
The buffer started. Call the endBuffer()
method when buffering completes.
tealium?.media?.startBuffer()
startChapter()
The chapter started. Call the endChapter()
method when the chapter completes.
tealium?.media?.startChapter(chapter)
Parameter | Type | Description |
---|---|---|
chapter |
Chapter |
The chapter segment name. |
Example:
tealium?.media?.startChapter(Chapter(name = "Chapter 1"))
startSeek()
The user started seeking. Call the endSeek()
method when seeking completes.
tealium?.media?.startSeek(position)
Parameter | Type | Description |
---|---|---|
position |
Int |
The index position in the media, in seconds, where seek started. |
Example:
tealium?.media?.startSeek(10)
startSession()
The session started. Call the endSession()
method when session completes.
tealium?.media?.startSession()
updatePlayerState()
The start or end of the player state.
tealium?.media?.updatePlayerState(state)
Parameter | Type | Description |
---|---|---|
state |
State constant |
The media state |
The following State
constants are available:
Value | Description |
---|---|
CLOSED_CAPTION |
Closed caption state type. |
FULLSCREEN |
Full screen state type. |
IN_FOCUS |
In focus state type. |
MUTE |
Mute state type. |
PICTURE_IN_PICTURE |
Picture in picture state type. |
Example:
tealium?.media?.updatePlayerState(fullscreen)
Learn more about the player state.
updateQOE()
Sets the quality of experience bitrate value in kilobits per second (kbps) of the current session.
tealium?.media?.updateQOE(rate)
Parameter | Type | Description |
---|---|---|
rate |
Int |
The bitrate value. |
Example:
tealium?.media?.updateQOE(1500)
Class: MediaContent
The MediaContent
class creates a media content object.
val mediaContent: MediaContent = MediaContent(
name: MEDIA_NAME,
streamType: MEDIA_STREAM_TYPE,
mediaType: MEDIA_TYPE,
qoe: MEDIA_QOE,
trackingType: MEDIA_TRACKING_TYPE,
state = MEDIA_STATE,
customID = MEDIA_CUSTOM_ID,
duration: MEDIA_DURATION,
playerName: MEDIA_PLAYER_NAME,
channelName: MEDIA_CHANNEL_NAME,
metadata: MEDIA_METADATA
)
Variable Name | Type | Description | Required |
---|---|---|---|
name |
String |
The name of the media content. | Yes |
streamType |
StreamType |
The type of media stream. | Yes |
mediaType |
MediaType |
The type of media (video or audio). | Yes |
qoe |
QoE |
The quality of experience bitrate value. | Yes |
trackingType |
TrackingType |
The level of event tracking. (default: TrackingType.FULL_PLAYBACK ) |
Yes |
state |
PlayerState |
The media player state type. | |
customId |
String |
The custom identifier name. | |
duration |
Int |
The media duration, in seconds, such as 130 |
|
playerName |
String |
The media player name. | |
channelName |
String |
The media channel name. | |
metadata |
[String: Any] |
Additional media metadata. |
Class: Ad
The Ad
class creates an ad object.
val ad = Ad(
id = MEDIA_AD_ID,
name = MEDIA_AD_NAME,
duration = MEDIA_AD_DURATION,
position = MEDIA_AD_POSITION,
advertiser = MEDIA_AD_ADVERTISER,
creativeId = MEDIA_AD_CREATIVE_ID,
campaignId = MEDIA_AD_CAMPAIGN_ID,
placementId = MEDIA_AD_PLACEMENT_ID,
siteId = MEDIA_AD_SITE_ID,
creativeUrl = MEDIA_AD_CREATIVE_URL,
numberOfLoads = MEDIA_AD_LOAD,
pod = MEDIA_AD_POD,
playerName = MEDIA_AD_PLAYER_NAME
)
Parameter | Type | Description | Required |
---|---|---|---|
name |
String |
The name of the ad. | Yes |
duration |
Double |
The ad duration, in seconds, such as 130 |
|
position |
Int |
The current index position of the ad, in seconds. | |
advertiser |
String |
The ad advertiser. | |
creativeId |
String |
The ad creative identifier. | |
campaignId |
String |
The ad campaign identifier. | |
placementId |
String |
The ad placement identifier. | |
siteId |
String |
The ad site identifier. | |
creativeUrl |
String |
The ad creative URL. | |
numberOfLoads |
Int |
The number of ad loads. | |
pod |
String |
The ad pod. | |
playerName |
String |
The ad player name. |
Class: AdBreak
The AdBreak
class creates an ad break object.
val adBreak = AdBreak(
id = MEDIA_AD_BREAK_ID,
name = MEDIA_AD_BREAK_NAME,
duration = MEDIA_AD_BREAK_DURATION,
index = MEDIA_AD_BREAK_INDEX,
position = MEDIA_AD_BREAK_POSITION
)
Parameter | Type | Description | Required |
---|---|---|---|
id |
String |
The ad break unique identifier. | |
name |
String |
The ad break name. | Yes |
duration |
Double |
The ad break duration, in seconds, such as 130 |
|
index |
Int |
The index of the ad break. | |
position |
Int |
The current index position of the ad break, in seconds. |
Class: Chapter
The Chapter
class creates a chapter object.
val chapterObject = Chapter(
name = MEDIA_CHAPTER_NAME,
duration = MEDIA_CHAPTER_DURATION,
position = MEDIA_CHAPTER_POSITION,
metadata = MEDIA_CHAPTER_METADATA
)
The following are the Chapter
object parameters. Parameters must be in order if you are not using parameter names, such as duration =
when creating the object.
Variable Name | Type | Description | Required |
---|---|---|---|
name |
String |
The name of the chapter. | Yes |
duration |
Double |
The chapter duration, in seconds, such as 130 |
|
position |
Int |
The chapter position index. | |
metadata |
[String: Any] |
Additional chapter media metadata. |
This page was last updated: January 7, 2023