Skip to content

Commit

Permalink
Do not notifyPause when buffering is starting (#271)
Browse files Browse the repository at this point in the history
  • Loading branch information
StaehliJ authored Oct 24, 2023
1 parent 17050e9 commit b84fbf7
Showing 1 changed file with 23 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class ComScoreTracker : MediaItemTracker {
* When used with MediaSessionService or MediaBrowser the size is always [Size.UNKNOWN]. When not connected the size is [Size.ZERO].
*/
private var isSurfaceConnected: Boolean = false
private var isBuffering: Boolean = false

init {
streamingAnalytics.setMediaPlayerName(MEDIA_PLAYER_NAME)
Expand Down Expand Up @@ -95,8 +96,8 @@ class ComScoreTracker : MediaItemTracker {

private fun notifyPlay(position: Long, window: Window) {
if (!isSurfaceConnected) return
DebugLogger.debug(TAG, "notifyPlay: $position")
notifyPosition(position, window)
DebugLogger.debug(TAG, "notifyPlay")
streamingAnalytics.notifyPlay()
}

Expand All @@ -105,9 +106,27 @@ class ComScoreTracker : MediaItemTracker {
streamingAnalytics.notifyEnd()
}

/**
* Notify buffer start
* ComScore SDK : Also for a buffering to be taken into account, the time elapsed between a call to notifyBufferStart and notifyBufferStop has to
* be bigger than 500ms. Otherwise our SDK will just ignore the notifyBufferStart.
*/
private fun notifyBufferStart() {
DebugLogger.debug(TAG, "notifyBufferStart")
streamingAnalytics.notifyBufferStart()
isBuffering = true
}

/**
* According to the comprehension of the documentation and after validation with ComScore team,
* [StreamingAnalytics.notifyBufferStop] isn't required.
*
* No! We shall call it for case seeking while in pause.
*/
private fun notifyBufferStop() {
DebugLogger.debug(TAG, "notifyBufferStop")
streamingAnalytics.notifyBufferStop()
isBuffering = false
}

/**
Expand Down Expand Up @@ -138,17 +157,6 @@ class ComScoreTracker : MediaItemTracker {
streamingAnalytics.startFromDvrWindowOffset(windowOffset)
}

/**
* According to the comprehension of the documentation and after validation with ComScore team,
* [StreamingAnalytics.notifyBufferStop] isn't required.
*
* No! We shall call it for case seeking while in pause.
*/
private fun notifyBufferStop() {
DebugLogger.debug(TAG, "notifyBufferStop: ")
streamingAnalytics.notifyBufferStop()
}

private inner class PlayerComponent : AnalyticsListener {
override fun onPlaybackParametersChanged(
eventTime: AnalyticsListener.EventTime,
Expand Down Expand Up @@ -194,7 +202,9 @@ class ComScoreTracker : MediaItemTracker {
if (isPlaying) {
notifyPlay(position, window)
} else {
notifyPause()
if (!isBuffering) {
notifyPause()
}
}
}

Expand Down

0 comments on commit b84fbf7

Please sign in to comment.