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() }