Skip to content

Commit ce36cdf

Browse files
daytime-emweb-flow
andauthored
Releases/v1.4.0 (#76)
## Updates * Add method for updating `CustomerData` (#75) ## Improvements * Track player dimensions when using the default PlayerView (or SurfaceView or TextureView) (#74) Co-authored-by: Emily Dixon <[email protected]> Co-authored-by: GitHub <[email protected]>
1 parent 088d2d8 commit ce36cdf

File tree

2 files changed

+54
-9
lines changed

2 files changed

+54
-9
lines changed

build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
plugins {
2-
id("com.android.application") version "8.7.3" apply false
3-
id("org.jetbrains.kotlin.android") version "2.0.21" apply false
4-
id("com.android.library") version "8.7.3" apply false
2+
id("com.android.application") version "8.8.2" apply false
3+
id("org.jetbrains.kotlin.android") version "2.1.10" apply false
4+
id("com.android.library") version "8.8.2" apply false
55
id("com.mux.gradle.android.mux-android-distribution") version "1.3.0" apply false
66
}
77

library/src/main/java/com/mux/player/MuxPlayer.kt

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
package com.mux.player
22

33
import android.content.Context
4+
import android.view.SurfaceView
5+
import android.view.TextureView
46
import androidx.media3.common.MediaItem
7+
import androidx.media3.common.Player
58
import androidx.media3.common.Player.Listener
69
import androidx.media3.datasource.DefaultDataSource
710
import androidx.media3.exoplayer.ExoPlayer
11+
import androidx.media3.exoplayer.analytics.AnalyticsListener
12+
import com.mux.player.MuxPlayer.Builder
13+
import com.mux.player.internal.Logger
814
import com.mux.player.internal.cache.MuxPlayerCache
9-
import com.mux.stats.sdk.core.model.CustomerData
10-
import com.mux.stats.sdk.muxstats.MuxStatsSdkMedia3
1115
import com.mux.player.internal.createLogcatLogger
12-
import com.mux.player.internal.Logger
1316
import com.mux.player.internal.createNoLogger
17+
import com.mux.player.media.MediaItems
1418
import com.mux.player.media.MuxDataSource
1519
import com.mux.player.media.MuxMediaSourceFactory
16-
import com.mux.player.media.MediaItems
20+
import com.mux.stats.sdk.core.model.CustomerData
1721
import com.mux.stats.sdk.muxstats.ExoPlayerBinding
1822
import com.mux.stats.sdk.muxstats.INetworkRequest
1923
import com.mux.stats.sdk.muxstats.MuxDataSdk
24+
import com.mux.stats.sdk.muxstats.MuxStatsSdkMedia3
2025
import com.mux.stats.sdk.muxstats.media3.BuildConfig as MuxDataBuildConfig
2126

2227
/**
@@ -46,11 +51,51 @@ class MuxPlayer private constructor(
4651
initialCustomerData: CustomerData,
4752
network: INetworkRequest? = null,
4853
exoPlayerBinding: ExoPlayerBinding? = null
49-
) : ExoPlayer by exoPlayer {
54+
) : Player by exoPlayer {
5055

5156
private var muxStats: MuxStatsSdkMedia3<ExoPlayer>? = null
5257
private var released: Boolean = false
5358

59+
/**
60+
* Updates the Mux [CustomerData] reported by this player. This data will be applied until you
61+
* change it again, or [release] this player.
62+
*/
63+
@Suppress("unused")
64+
fun updateCustomerData(customerData: CustomerData) {
65+
muxStats?.updateCustomerData(customerData)
66+
}
67+
68+
@Suppress("unused")
69+
fun addAnalyticsListener(listener: AnalyticsListener) {
70+
exoPlayer.addAnalyticsListener(listener)
71+
}
72+
73+
/**
74+
* This method is optional. Mux Player automatically detects the size of the your player view
75+
*
76+
* Records the size of the player. You don't need to call this if you're using the default
77+
* `PlayerView`, or a [SurfaceView] or [TextureView].
78+
*
79+
* @param widthPx The width of the player view, in px
80+
* @param heightPx The height of the player view, in px
81+
*/
82+
@Suppress("unused")
83+
fun recordPlayerSize(widthPx: Int, heightPx: Int) {
84+
muxStats?.setPlayerSize(widthPx, heightPx)
85+
}
86+
87+
override fun setVideoSurfaceView(surfaceView: SurfaceView?) {
88+
// We don't need the whole PlayerView, the surface (inside surfaceView) is where content goes
89+
muxStats?.setPlayerView(surfaceView)
90+
exoPlayer.setVideoSurfaceView(surfaceView)
91+
}
92+
93+
override fun setVideoTextureView(textureView: TextureView?) {
94+
// We don't need the whole PlayerView, the surface (inside textureView) is where content goes
95+
muxStats?.setPlayerView(textureView)
96+
exoPlayer.setVideoTextureView(textureView)
97+
}
98+
5499
override fun release() {
55100
// good to release muxStats first, so it doesn't call to the player after release
56101
muxStats?.release()
@@ -95,7 +140,7 @@ class MuxPlayer private constructor(
95140
context = context,
96141
envKey = muxDataKey ?: "", // empty string should infer the key
97142
customerData = initialCustomerData,
98-
player = this,
143+
player = exoPlayer,
99144
playerView = null,
100145
customOptions = null,
101146
device = muxPlayerDevice,

0 commit comments

Comments
 (0)