From 19a5664b7bd2763edcf35794173d6c56255aaaaa Mon Sep 17 00:00:00 2001 From: Emily Dixon Date: Tue, 6 Aug 2024 16:32:21 -0700 Subject: [PATCH] Releases/v1.3.1 ## Improvements * fix: enable() should reset the internal state + fix holding onto stale playhead time (#66) Co-authored-by: Emily Dixon Co-authored-by: GitHub --- .../java/com/mux/stats/sdk/muxstats/MuxDataSdk.kt | 5 ++++- .../com/mux/stats/sdk/muxstats/MuxStateCollector.kt | 12 +++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/core-android/src/main/java/com/mux/stats/sdk/muxstats/MuxDataSdk.kt b/core-android/src/main/java/com/mux/stats/sdk/muxstats/MuxDataSdk.kt index c9fb7d2..b245e2c 100644 --- a/core-android/src/main/java/com/mux/stats/sdk/muxstats/MuxDataSdk.kt +++ b/core-android/src/main/java/com/mux/stats/sdk/muxstats/MuxDataSdk.kt @@ -202,7 +202,10 @@ abstract class MuxDataSdk @JvmOverloads protected con * @param customerData [CustomerData] with metadata about the new view * @see CustomerData */ - open fun enable(customerData: CustomerData) = muxStats.enable(customerData) + open fun enable(customerData: CustomerData) { + collector.resetState() + muxStats.enable(customerData) + } /** * Dispatch a raw event to the View. Please use this method with caution, as unexpected events can diff --git a/core-android/src/main/java/com/mux/stats/sdk/muxstats/MuxStateCollector.kt b/core-android/src/main/java/com/mux/stats/sdk/muxstats/MuxStateCollector.kt index e803cee..cab43c8 100644 --- a/core-android/src/main/java/com/mux/stats/sdk/muxstats/MuxStateCollector.kt +++ b/core-android/src/main/java/com/mux/stats/sdk/muxstats/MuxStateCollector.kt @@ -409,6 +409,7 @@ open class MuxStateCollector( */ @Suppress("unused") fun programChange(customerVideoData: CustomerVideoData) { + // keep current play state, since the actual stream should still be playing reset() muxStats.programChange(customerVideoData) } @@ -420,9 +421,17 @@ open class MuxStateCollector( */ @Suppress("unused") fun videoChange(customerVideoData: CustomerVideoData) { + resetState() + muxStats.videoChange(customerVideoData) + } + + /** + * Returns the Collector to the state where it has processed no events. + */ + @Suppress("MemberVisibilityCanBePrivate") + fun resetState() { _playerState = MuxPlayerState.INIT reset() - muxStats.videoChange(customerVideoData) } /** @@ -526,6 +535,7 @@ open class MuxStateCollector( seekedEventsSent = 0 firstFrameReceived = false firstFrameRenderedAtMillis = FIRST_FRAME_NOT_RENDERED + playbackPositionMills = TIME_UNKNOWN allowedHeaders.clear() }