Skip to content

Commit

Permalink
Releases/v1.5.0 (#87)
Browse files Browse the repository at this point in the history
## Improvements

* Update Android Core to 1.3.0
* misc. local build updates
  • Loading branch information
daytime-em authored Aug 2, 2024
1 parent 62b129b commit 86b79ad
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 21 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import org.jetbrains.dokka.gradle.DokkaTaskPartial
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '8.4.1' apply false
id 'com.android.library' version '8.4.1' apply false
id 'com.android.application' version '8.4.2' apply false
id 'com.android.library' version '8.4.2' apply false
id 'org.jetbrains.kotlin.android' version '1.9.24' apply false
id 'com.mux.gradle.android.mux-android-distribution' version '1.1.2' apply false
id "org.jetbrains.dokka" version "1.6.10"
}

allprojects {
project.ext {
coreVersion = '1.2.2'
coreVersion = '1.3.0'
}

tasks.withType(DokkaTaskPartial.class) {
Expand Down
6 changes: 5 additions & 1 deletion library-exo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ android {
namespace 'com.mux.stats.sdk.muxstats.media3_exo'
compileSdk 34

buildFeatures {
buildConfig = true
}

defaultConfig {
minSdk 16
minSdk 19
targetSdk 34

// our deps almost blow the dex limit by themselves, media3 doc/examples all use multidex
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.mux.stats.sdk.muxstats

import android.util.Log
import androidx.annotation.OptIn
import androidx.media3.common.Format
import androidx.media3.common.MediaItem
Expand Down Expand Up @@ -43,6 +42,7 @@ open class ExoPlayerBinding : MuxPlayerAdapter.PlayerBinding<ExoPlayer> {

override fun bindPlayer(player: ExoPlayer, collector: MuxStateCollector) {
catchUpPlayState(player, collector)
catchUpStreamData(player, collector)

listener = MuxAnalyticsListener(
player = player,
Expand Down Expand Up @@ -74,20 +74,6 @@ open class ExoPlayerBinding : MuxPlayerAdapter.PlayerBinding<ExoPlayer> {
errorBinding.unbindPlayer(player, collector)
}

// Catches the Collector up to the current play state if the user registers after prepare()
private fun catchUpPlayState(player: ExoPlayer, collector: MuxStateCollector) {
MuxLogger.d("PlayerUtils", "catchUpPlayState: Called. pwr is ${player.playWhenReady}")
if (player.playWhenReady) {
// Captures auto-play & late-registration, setting state and sending 'viewstart'
collector.play()
}
// The player will be idle when we are first attached, so we don't need to say we paused
// (which is how IDLE is handled during actual playback)
if (player.playbackState != Player.STATE_IDLE) {
collector.handleExoPlaybackState(player.playbackState, player.playWhenReady)
}
}

companion object {
@Suppress("unused")
private const val TAG = "ExoPlayerBinding"
Expand Down
6 changes: 5 additions & 1 deletion library-ima/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ android {
namespace 'com.mux.stats.sdk.media3_ima'
compileSdk 34

buildFeatures {
buildConfig = true
}

defaultConfig {
targetSdk 34
minSdk 16
minSdk 19

// our deps almost blow the dex limit by themselves, media3 doc/examples all use multidex
multiDexEnabled true
Expand Down
6 changes: 5 additions & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ android {
namespace 'com.mux.stats.sdk.muxstats.media3'
compileSdk 34

buildFeatures {
buildConfig = true
}

defaultConfig {
minSdk 16
minSdk 19
targetSdk 34

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ class MuxStatsSdkMedia3<P : Player> @JvmOverloads constructor(
* The player bound to this object
*/
val boundPlayer: P get() { return player }

override fun enable(customerData: CustomerData) {
// call-through to start the new view
super.enable(customerData)
// catch-up player state in case we missed prepare()
catchUpPlayState(player, collector)
catchUpStreamData(player, collector)
}
}

/**
Expand Down
30 changes: 30 additions & 0 deletions library/src/main/java/com/mux/stats/sdk/muxstats/PlayerUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import androidx.media3.common.Format
import androidx.media3.common.MediaItem
import androidx.media3.common.MediaMetadata
import androidx.media3.common.Player
import androidx.media3.common.Timeline
import androidx.media3.common.Tracks
import com.mux.android.util.oneOf
import com.mux.stats.sdk.core.model.VideoData
Expand Down Expand Up @@ -35,6 +36,35 @@ fun <R> Tracks.Group.mapFormats(block: (Format) -> R): List<R> {
return retList
}

// Catches the Collector up to the current play state if the user registers after prepare()
@JvmSynthetic
fun catchUpPlayState(player: Player, collector: MuxStateCollector) {
MuxLogger.d("PlayerUtils", "catchUpPlayState: Called. pwr is ${player.playWhenReady}")
if (player.playWhenReady) {
// Captures auto-play & late-registration, setting state and sending 'viewstart'
collector.play()
}
// The player will be idle when we are first attached, so we don't need to say we paused
// (which is how IDLE is handled during actual playback)
if (player.playbackState != Player.STATE_IDLE) {
collector.handleExoPlaybackState(player.playbackState, player.playWhenReady)
}
}

@JvmSynthetic
fun catchUpStreamData(player: Player, collector: MuxStateCollector) {
player.currentTimeline.takeIf { it.windowCount > 0 }?.let { tl ->
val window = Timeline.Window().apply { tl.getWindow(0, this) }
collector.sourceDurationMs = window.durationMs
}
@Suppress("UNNECESSARY_SAFE_CALL")
player.videoSize?.let {
collector.sourceWidth = it.width
collector.sourceHeight = it.height
}
player.currentMediaItem?.let { collector.handleMediaItemChanged(it) }
}

/**
* Handles an ExoPlayer position discontinuity
*/
Expand Down

0 comments on commit 86b79ad

Please sign in to comment.