Skip to content

Commit 81ea56e

Browse files
authored
Releases/v1.4.9 (#82)
## Improvements * fix: player IDs not unique (#81)
1 parent 7cb6698 commit 81ea56e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

library/src/main/java/com/mux/stats/sdk/muxstats/MuxDataSdk.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import com.mux.stats.sdk.muxstats.MuxDataSdk.AndroidDevice
2626
import kotlinx.coroutines.CoroutineScope
2727
import kotlinx.coroutines.Dispatchers
2828
import java.util.*
29+
import java.util.concurrent.atomic.AtomicInteger
2930

3031
/**
3132
* Base class for Mux Data SDK facades for Android. This class provides some structure to hold a
@@ -327,12 +328,16 @@ abstract class MuxDataSdk<Player, PlayerView : View> @JvmOverloads protected con
327328
enum class LogcatLevel { NONE, DEBUG, VERBOSE }
328329

329330
protected companion object Factory {
331+
332+
private val nextPlayerId = AtomicInteger(0)
333+
330334
/**
331335
* Generates a player ID based off the containing context and the ID of the View being used for
332336
* playback
333337
*/
334338
fun generatePlayerId(context: Context, view: View?) =
335-
context.javaClass.canonicalName!! + (view?.id ?: "audio")
339+
context.javaClass.canonicalName!! + "-" + (view?.id ?: "no-view") +
340+
"-" + nextPlayerId.getAndIncrement()
336341

337342
fun defaultPlayerListener(outerSdk: MuxDataSdk<*, *>): IPlayerListener =
338343
outerSdk.PlayerListenerBase()

0 commit comments

Comments
 (0)