Skip to main content

Triton audio player

The Quickplay Audio Player supports Client-Side Ad Insertion (CSAI) for both VOD and Live Audio content, enabling seamless ad playback with video pre-rolls.

Triton cue points for live streaming

For live audio streams, the Triton player listens to Triton cue points, which lets you track tracks and advertisements in real time. This ensures accurate ad playback and metadata synchronization.

Setup

Complete the following steps to enable audio playback functionality.

  1. Add the following permissions and service to your AndroidManifest.xml:
<manifest>
<!-- Add the necessary permissions -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

<service
android:name=".AudioBrowserService"
android:enabled="true"
android:exported="true"
android:foregroundServiceType="mediaPlayback">
<intent-filter>
<action android:name="android.media.browse.MediaBrowserService"/>
</intent-filter>
</service>
</manifest>
  1. Start the Audio Player Service. The audio player service must be started at launch of the application.
TritonPlayerFactory.prepareAudioPlayerService()

Create the Triton player

You can create the triton audio player by configuring it with the required parameters, such as the stream connection configuration and playback session configuration.

// Creates [TritonPlayer] instance that plays Triton audio streams.
val tritonPlayer = TritonPlayerFactory.createTritonAudioPlayer(
tritonStreamConfig,
playbackConfig,
PlayerNotificationProperties.Builder().build(),
)

Parameters

Property NameTypeDescription
streamConnectionConfigTritonAudioStreamConnectionConfigRepresents Triton end points connectivity information.
playbackSessionConfigTritonAudioPlaybackSessionConfigDeclares the configuration properties for [TritonPlayer] playback session initialization.
playerNotificationPropertiesPlayerNotificationProperties instanceEncapsulates all the configurable properties applicable for audio playback to post the player notification.

Create TritonAudioStreamConnectionConfig

This configuration handles the stream connection. You can set it up for live or on-demand content.

Parameters

Property NameTypeDescription
contentURLStringThe primary URL to start Triton audio stream playback session. session with [contentURL].
sidebandMetadataURLStringThe primary URL to retrieve sideband metadata. NOTE: that this attribute is not applicable on on-demand content.
playerNotificationPropertiesIntThe number of attempts trying to establish previously failed connection to sideband metadata end point.
sidebandMetadataConnectionRetryDelayFactorMsLongThe reconnection retry delay factor, in milliseconds, used in exponential back-off retry computation. This scheme is used in order to prevent excessive simultaneous requests hitting servers.
val tritonStreamConfig = if (isLive)
TritonAudioStreamConnectionConfig(
contentURL,
sidebandMetadataURL = siedbandMetadataUrl
) else
TritonAudioStreamConnectionConfig(contentURL)

Create TritonAudioPlaybackSessionConfig

Create an IMA targeted AdRequest instance.

val adRequest: CSAIAdsRequest? = playbackItem.adURL?.let {
CSAIAdsRequest(
it,
adOverlayUIScopes
)
}

To create a playback configuration for the audio player, you can use the following snippet:

val playbackConfig = TritonAudioPlaybackSessionConfig(
playbackProperties = playbackPropertiesBuilder.build(),
mediaType = playbackItem.mediaType,
adRequest = adRequest,
mediaMetadata = mediaMetadata
)

Listen to Triton track and ad events

override fun onEventReceived(
streamTimelineEvent: StreamTimelineEvent,
suggestedAction: Action,
streamTimelineMetadata: StreamTimelineMetadata?
) {
when (streamTimelineEvent) {
StreamTimelineEvent.TRITON_AUDIO_MEDIA_TRACK -> {
when (suggestedAction) {
Action.DISPLAY -> {
// Display the Track event
}
Action.HIDE -> {
// Hide the Track event
}
}
StreamTimelineEvent.TRITON_AD -> {
when (suggestedAction) {
Action.DISPLAY -> {
// Display the Ad event
}
Action.HIDE -> {
// Hide the Ad event
}
}
}
}
}
}