Skip to main content

didUpdatePlaybackProgressOfClip

Notifies the SDK of the playback progress of the currently-played key play clip.

Overview

Call this method periodically during clip playback to inform the SDK of the current playback progress. The SDK uses this information to update progress indicators and synchronize UI elements. Progress should be reported as a value between 0.0 (start) and 1.0 (complete).

Syntax

abstract fun didUpdatePlaybackProgressOfClip(index: Int, progress: Float)

Parameters

ParameterTypeDescription
indexIntThe index of the clip being played
progressFloatPlayback progress from 0.0 (start) to 1.0 (complete)

Example

// Update progress during playback
fun onClipProgressUpdate(clipIndex: Int, currentTime: Long, duration: Long) {
val progress = if (duration > 0) {
(currentTime.toFloat() / duration.toFloat()).coerceIn(0f, 1f)
} else {
0f
}
viewModel.didUpdatePlaybackProgressOfClip(clipIndex, progress)
}

// In a video player progress callback
videoPlayer.setOnProgressUpdateListener { position, duration ->
val currentIndex = getCurrentPlayingClipIndex()
val progress = position.toFloat() / duration.toFloat()
viewModel.didUpdatePlaybackProgressOfClip(currentIndex, progress)
}

// With periodic updates
private var progressJob: Job? = null

fun startProgressUpdates(clipIndex: Int) {
progressJob = lifecycleScope.launch {
while (isActive) {
val progress = videoPlayer.getCurrentPosition().toFloat() /
videoPlayer.getDuration().toFloat()
viewModel.didUpdatePlaybackProgressOfClip(clipIndex, progress)
delay(100) // Update every 100ms
}
}
}

fun stopProgressUpdates() {
progressJob?.cancel()
}

Notes

  • Report progress as a value between 0.0 and 1.0
  • Update progress periodically (e.g., every 100-500ms)
  • The SDK uses this for progress bars and scrubbing
  • Stop sending updates when playback stops
  • Calculate progress as: currentPosition / totalDuration