Skip to content

Releases/v1.4.0 #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id("com.android.application") version "8.7.3" apply false
id("org.jetbrains.kotlin.android") version "2.0.21" apply false
id("com.android.library") version "8.7.3" apply false
id("com.android.application") version "8.8.2" apply false
id("org.jetbrains.kotlin.android") version "2.1.10" apply false
id("com.android.library") version "8.8.2" apply false
id("com.mux.gradle.android.mux-android-distribution") version "1.3.0" apply false
}

Expand Down
57 changes: 51 additions & 6 deletions library/src/main/java/com/mux/player/MuxPlayer.kt
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
package com.mux.player

import android.content.Context
import android.view.SurfaceView
import android.view.TextureView
import androidx.media3.common.MediaItem
import androidx.media3.common.Player
import androidx.media3.common.Player.Listener
import androidx.media3.datasource.DefaultDataSource
import androidx.media3.exoplayer.ExoPlayer
import androidx.media3.exoplayer.analytics.AnalyticsListener
import com.mux.player.MuxPlayer.Builder
import com.mux.player.internal.Logger
import com.mux.player.internal.cache.MuxPlayerCache
import com.mux.stats.sdk.core.model.CustomerData
import com.mux.stats.sdk.muxstats.MuxStatsSdkMedia3
import com.mux.player.internal.createLogcatLogger
import com.mux.player.internal.Logger
import com.mux.player.internal.createNoLogger
import com.mux.player.media.MediaItems
import com.mux.player.media.MuxDataSource
import com.mux.player.media.MuxMediaSourceFactory
import com.mux.player.media.MediaItems
import com.mux.stats.sdk.core.model.CustomerData
import com.mux.stats.sdk.muxstats.ExoPlayerBinding
import com.mux.stats.sdk.muxstats.INetworkRequest
import com.mux.stats.sdk.muxstats.MuxDataSdk
import com.mux.stats.sdk.muxstats.MuxStatsSdkMedia3
import com.mux.stats.sdk.muxstats.media3.BuildConfig as MuxDataBuildConfig

/**
Expand Down Expand Up @@ -46,11 +51,51 @@ class MuxPlayer private constructor(
initialCustomerData: CustomerData,
network: INetworkRequest? = null,
exoPlayerBinding: ExoPlayerBinding? = null
) : ExoPlayer by exoPlayer {
) : Player by exoPlayer {

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

/**
* Updates the Mux [CustomerData] reported by this player. This data will be applied until you
* change it again, or [release] this player.
*/
@Suppress("unused")
fun updateCustomerData(customerData: CustomerData) {
muxStats?.updateCustomerData(customerData)
}

@Suppress("unused")
fun addAnalyticsListener(listener: AnalyticsListener) {
exoPlayer.addAnalyticsListener(listener)
}

/**
* This method is optional. Mux Player automatically detects the size of the your player view
*
* Records the size of the player. You don't need to call this if you're using the default
* `PlayerView`, or a [SurfaceView] or [TextureView].
*
* @param widthPx The width of the player view, in px
* @param heightPx The height of the player view, in px
*/
@Suppress("unused")
fun recordPlayerSize(widthPx: Int, heightPx: Int) {
muxStats?.setPlayerSize(widthPx, heightPx)
}

override fun setVideoSurfaceView(surfaceView: SurfaceView?) {
// We don't need the whole PlayerView, the surface (inside surfaceView) is where content goes
muxStats?.setPlayerView(surfaceView)
exoPlayer.setVideoSurfaceView(surfaceView)
}

override fun setVideoTextureView(textureView: TextureView?) {
// We don't need the whole PlayerView, the surface (inside textureView) is where content goes
muxStats?.setPlayerView(textureView)
exoPlayer.setVideoTextureView(textureView)
}

override fun release() {
// good to release muxStats first, so it doesn't call to the player after release
muxStats?.release()
Expand Down Expand Up @@ -95,7 +140,7 @@ class MuxPlayer private constructor(
context = context,
envKey = muxDataKey ?: "", // empty string should infer the key
customerData = initialCustomerData,
player = this,
player = exoPlayer,
playerView = null,
customOptions = null,
device = muxPlayerDevice,
Expand Down
Loading