Skip to content

Commit

Permalink
feat: add external customer data escape hatch
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewjl-mux committed Sep 16, 2024
1 parent d3cbc8d commit 9fe88cc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion library/src/main/java/com/mux/player/MuxPlayer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class MuxPlayer private constructor(
private val muxDataKey: String?,
private val logger: Logger,
private val muxCacheEnabled: Boolean = true,
private val didAddMonitoringData: Boolean = false,
context: Context,
initialCustomerData: CustomerData,
network: INetworkRequest? = null,
Expand Down Expand Up @@ -75,7 +76,7 @@ class MuxPlayer private constructor(
override fun onMediaItemTransition(mediaItem: MediaItem?, reason: Int) {
// Check if a DRM token is set, set View Drm Type if it is
// TODO: escape hatch TBA
if (mediaItem?.requestMetadata?.extras?.getString(Constants.BUNDLE_DRM_TOKEN) != null) {
if (mediaItem?.requestMetadata?.extras?.getString(Constants.BUNDLE_DRM_TOKEN) != null && !didAddMonitoringData) {
val viewData = CustomerViewData()
// Assumes only widevine DRM playback is supported
// If playready support is added in future, update to select between widevine and playready
Expand Down Expand Up @@ -152,6 +153,7 @@ class MuxPlayer private constructor(
private var enableSmartCache: Boolean = false
private var logger: Logger? = null
private var customerData: CustomerData = CustomerData()
private var didAddMonitoringData: Boolean = false
private var exoPlayerBinding: ExoPlayerBinding? = null
private var network: INetworkRequest? = null

Expand Down Expand Up @@ -205,6 +207,7 @@ class MuxPlayer private constructor(
@Suppress("unused")
fun addMonitoringData(customerData: CustomerData): Builder {
this.customerData.update(customerData)
this.didAddMonitoringData = true
return this
}

Expand Down Expand Up @@ -257,6 +260,7 @@ class MuxPlayer private constructor(
exoPlayer = this.playerBuilder.build(),
muxDataKey = this.dataEnvKey,
muxCacheEnabled = enableSmartCache,
didAddMonitoringData = this.didAddMonitoringData,
logger = logger ?: createNoLogger(),
initialCustomerData = customerData,
network = network,
Expand Down

0 comments on commit 9fe88cc

Please sign in to comment.