Skip to content

Commit d314ca0

Browse files
daytime-emweb-flow
andauthored
Releases/v1.5.0 (#88)
## Updates * Add incubating `playbackModeChange` API (#87) * Update to Kotlin 2.2.10 Co-authored-by: Emily Dixon <edixon@mux.com> Co-authored-by: GitHub <noreply@github.com>
1 parent 3409399 commit d314ca0

File tree

5 files changed

+74
-32
lines changed

5 files changed

+74
-32
lines changed

app/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ plugins {
55

66
android {
77
namespace = "com.mux.app"
8-
compileSdk = 35
8+
compileSdk = 36
99

1010
defaultConfig {
1111
applicationId = "com.mux.app"
1212
minSdk = 24
13-
targetSdk = 35
13+
targetSdk = 36
1414
versionCode = 1
1515
versionName = "1.0"
1616

build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
plugins {
2-
id 'com.android.application' version '8.8.1' apply false
3-
id 'com.android.library' version '8.8.1' apply false
4-
id 'org.jetbrains.kotlin.android' version '1.9.24' apply false
2+
id 'com.android.application' version '8.8.2' apply false
3+
id 'com.android.library' version '8.8.2' apply false
4+
id 'org.jetbrains.kotlin.android' version '2.2.10' apply false
55
id 'com.mux.gradle.android.mux-android-distribution' version '1.3.0' apply false
66
}

library/build.gradle

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@ plugins {
55
}
66

77
android {
8-
compileSdk 35
8+
compileSdk 36
99

1010
namespace "com.mux.core_android"
1111

1212
defaultConfig {
1313
minSdk 16
14-
//noinspection EditedTargetSdkVersion
15-
targetSdk 35
1614

1715
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1816
consumerProguardFiles "consumer-rules.pro"
@@ -75,6 +73,7 @@ muxDistribution {
7573

7674
dependencies {
7775
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.1"
76+
implementation 'androidx.annotation:annotation-jvm:1.9.1'
7877

7978
// dynamic version/compileOnly so the player SDKs on top of this can update core independently
8079
//noinspection GradleDynamicVersion

library/src/main/java/com/mux/android/util/Weak.kt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,12 @@ fun <T> weak(): ReadWriteProperty<Any, T?> = Weak(null)
2525
*/
2626
private class Weak<T>(referent: T?) : ReadWriteProperty<Any, T?> {
2727
private var weakT = WeakReference(referent)
28-
private var onSet: ((T?) -> Unit)? = null
2928

30-
fun onSet(block: (T?) -> Unit): Weak<T> {
31-
onSet = block
32-
return this
29+
override fun getValue(thisRef: Any, property: KProperty<*>): T? {
30+
return weakT.get()
3331
}
3432

35-
override fun getValue(thisRef: Any, property: KProperty<*>): T? = weakT.get()
36-
3733
override fun setValue(thisRef: Any, property: KProperty<*>, value: T?) {
38-
onSet?.invoke(value)
3934
weakT = WeakReference(value)
4035
}
4136
}

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

Lines changed: 65 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import android.os.Build
1212
import android.os.SystemClock
1313
import android.util.Log
1414
import android.view.View
15+
import androidx.annotation.RequiresApi
1516
import com.mux.android.util.convertPxToDp
1617
import com.mux.android.util.oneOf
1718
import com.mux.android.util.weak
@@ -25,6 +26,7 @@ import com.mux.stats.sdk.core.util.MuxLogger
2526
import com.mux.stats.sdk.muxstats.MuxDataSdk.AndroidDevice
2627
import kotlinx.coroutines.CoroutineScope
2728
import kotlinx.coroutines.Dispatchers
29+
import org.json.JSONObject
2830
import java.util.*
2931
import java.util.concurrent.atomic.AtomicInteger
3032

@@ -184,6 +186,56 @@ abstract class MuxDataSdk<Player, PlayerView : View> @JvmOverloads protected con
184186
open fun orientationChange(orientation: MuxSDKViewOrientation) =
185187
muxStats.orientationChange(orientation)
186188

189+
/**
190+
* Call when the video is presented in a particular way, eg, fullscreen, or picture-in-picture
191+
*
192+
* You can call this method immediately after starting a view, or wait until a relevant change.
193+
* If you do the latter, the mode will be [PlaybackMode.STANDARD] until you change it.
194+
*
195+
* @param mode The playback mode being entered
196+
*/
197+
open fun playbackModeChange(mode: PlaybackMode) {
198+
muxStats.playbackModeChange(mode, null as JSONObject?)
199+
}
200+
201+
/**
202+
* Call when the video is presented in a particular way, eg, fullscreen, or picture-in-picture
203+
*
204+
* You can call this method immediately after starting a view, or wait until a relevant change.
205+
* If you do the latter, the mode will be [PlaybackMode.STANDARD] until you change it.
206+
*
207+
* @param mode The playback mode being entered
208+
* @param extraData Extra data to accompany this event. Will appear in the event timeline for your view
209+
*/
210+
open fun playbackModeChange(mode: PlaybackMode, extraData: JSONObject) {
211+
muxStats.playbackModeChange(mode, extraData)
212+
}
213+
214+
/**
215+
* Call when the video is presented in a particular way, eg, fullscreen, or picture-in-picture
216+
*
217+
* You can call this method immediately after starting a view, or wait until a relevant change.
218+
* If you do the latter, the mode will be [PlaybackMode.STANDARD] until you change it.
219+
*
220+
* @param customMode The playback mode being entered
221+
*/
222+
open fun playbackModeChange(customMode: String) {
223+
muxStats.playbackModeChange(customMode, null as JSONObject?)
224+
}
225+
226+
/**
227+
* Call when the video is presented in a particular way, eg, fullscreen, or picture-in-picture
228+
*
229+
* You can call this method immediately after starting a view, or wait until a relevant change.
230+
* If you do the latter, the mode will be [PlaybackMode.STANDARD] until you change it.
231+
*
232+
* @param customMode The playback mode being entered
233+
* @param extraData Extra data to accompany this event. Will appear in the event timeline for your view
234+
*/
235+
open fun playbackModeChange(customMode: String, extraData: JSONObject) {
236+
muxStats.playbackModeChange(customMode, extraData)
237+
}
238+
187239
/**
188240
* Call when the presentation of the video changes, ie Fullscreen vs Normal, etc
189241
*/
@@ -459,47 +511,43 @@ abstract class MuxDataSdk<Player, PlayerView : View> @JvmOverloads protected con
459511
connectionTypeApi16()
460512
}
461513

462-
@TargetApi(Build.VERSION_CODES.M)
514+
@RequiresApi(Build.VERSION_CODES.M)
463515
private fun connectionTypeApi23(): String? {
464-
contextRef?.let { context ->
516+
// use let{} so we get both a null-check and a hard ref
517+
return contextRef?.let { context ->
465518
val connectivityManager = context.getSystemService(ConnectivityManager::class.java)
466519
val nc: NetworkCapabilities? =
467520
connectivityManager.getNetworkCapabilities(connectivityManager.activeNetwork)
468521

469-
return when {
522+
when {
470523
nc == null -> {
471524
MuxLogger.w(TAG, "Could not get network capabilities")
472525
null
473526
}
474527

475-
nc.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET) -> {
528+
nc.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET) ->
476529
CONNECTION_TYPE_WIRED
477-
}
478530

479-
nc.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) -> {
531+
nc.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) ->
480532
CONNECTION_TYPE_WIFI
481-
}
482533

483-
nc.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) -> {
534+
nc.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) ->
484535
CONNECTION_TYPE_CELLULAR
485-
}
486536

487-
else -> {
488-
CONNECTION_TYPE_OTHER
489-
}
537+
else -> CONNECTION_TYPE_OTHER
490538
}
491-
} ?: return null
539+
}
492540
}
493541

494542
@Suppress("DEPRECATION") // Uses deprecated APIs for backward compat
495543
private fun connectionTypeApi16(): String? {
496-
// use let{} so we get both a null-check and a hard ref for the check
497-
contextRef?.let { context ->
544+
// use let{} so we get both a null-check and a hard ref
545+
return contextRef?.let { context ->
498546
val connectivityMgr = context
499547
.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
500548
val activeNetwork: NetworkInfo? = connectivityMgr.activeNetworkInfo
501549

502-
return if (activeNetwork == null) {
550+
if (activeNetwork == null) {
503551
MuxLogger.w(TAG, "Couldn't obtain network info")
504552
null
505553
} else {
@@ -526,7 +574,7 @@ abstract class MuxDataSdk<Player, PlayerView : View> @JvmOverloads protected con
526574
}
527575
}
528576
}
529-
} ?: return null // contextRef?.let {...
577+
} // contextRef?.let {...
530578
}
531579

532580
override fun getElapsedRealtime(): Long {

0 commit comments

Comments
 (0)