1
1
package com.mux.player
2
2
3
3
import android.content.Context
4
+ import android.view.SurfaceView
5
+ import android.view.TextureView
4
6
import androidx.media3.common.MediaItem
7
+ import androidx.media3.common.Player
5
8
import androidx.media3.common.Player.Listener
6
9
import androidx.media3.datasource.DefaultDataSource
7
10
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
8
14
import com.mux.player.internal.cache.MuxPlayerCache
9
- import com.mux.stats.sdk.core.model.CustomerData
10
- import com.mux.stats.sdk.muxstats.MuxStatsSdkMedia3
11
15
import com.mux.player.internal.createLogcatLogger
12
- import com.mux.player.internal.Logger
13
16
import com.mux.player.internal.createNoLogger
17
+ import com.mux.player.media.MediaItems
14
18
import com.mux.player.media.MuxDataSource
15
19
import com.mux.player.media.MuxMediaSourceFactory
16
- import com.mux.player.media.MediaItems
20
+ import com.mux.stats.sdk.core.model.CustomerData
17
21
import com.mux.stats.sdk.muxstats.ExoPlayerBinding
18
22
import com.mux.stats.sdk.muxstats.INetworkRequest
19
23
import com.mux.stats.sdk.muxstats.MuxDataSdk
24
+ import com.mux.stats.sdk.muxstats.MuxStatsSdkMedia3
20
25
import com.mux.stats.sdk.muxstats.media3.BuildConfig as MuxDataBuildConfig
21
26
22
27
/* *
@@ -46,7 +51,7 @@ class MuxPlayer private constructor(
46
51
initialCustomerData : CustomerData ,
47
52
network : INetworkRequest ? = null ,
48
53
exoPlayerBinding : ExoPlayerBinding ? = null
49
- ) : ExoPlayer by exoPlayer {
54
+ ) : Player by exoPlayer {
50
55
51
56
private var muxStats: MuxStatsSdkMedia3 <ExoPlayer >? = null
52
57
private var released: Boolean = false
@@ -55,10 +60,42 @@ class MuxPlayer private constructor(
55
60
* Updates the Mux [CustomerData] reported by this player. This data will be applied until you
56
61
* change it again, or [release] this player.
57
62
*/
63
+ @Suppress(" unused" )
58
64
fun updateCustomerData (customerData : CustomerData ) {
59
65
muxStats?.updateCustomerData(customerData)
60
66
}
61
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
+
62
99
override fun release () {
63
100
// good to release muxStats first, so it doesn't call to the player after release
64
101
muxStats?.release()
@@ -103,7 +140,7 @@ class MuxPlayer private constructor(
103
140
context = context,
104
141
envKey = muxDataKey ? : " " , // empty string should infer the key
105
142
customerData = initialCustomerData,
106
- player = this ,
143
+ player = exoPlayer ,
107
144
playerView = null ,
108
145
customOptions = null ,
109
146
device = muxPlayerDevice,
0 commit comments