clipDidFailToPlay
Notifies the SDK that the user tried to play a clip but it failed to play back.
Overview
Call this method when a clip fails to start playing due to network errors, codec issues, or other playback problems. This allows the SDK to display an appropriate error state and potentially retry or suggest alternatives.
Syntax
abstract fun clipDidFailToPlay(index: Int)
Parameters
| Parameter | Type | Description |
|---|---|---|
index | Int | The index of the clip that failed to play |
Example
// When clip playback fails
fun onClipPlaybackError(clipIndex: Int, error: Exception) {
Log.e("Maestro", "Clip $clipIndex failed to play", error)
viewModel.clipDidFailToPlay(clipIndex)
}
// In playClip implementation
override fun playClip(index: Int, clipId: String?) {
lifecycleScope.launch {
try {
val clip = getClipAtIndex(index)
videoPlayer.play(clip)
viewModel.didStartPlayingClip(index)
} catch (e: Exception) {
// Notify SDK of failure
viewModel.clipDidFailToPlay(index)
// Show error to user
showErrorMessage("Unable to play clip")
}
}
}
// In video player error callback
videoPlayer.setOnErrorListener { clip, error ->
val index = getClipIndex(clip)
viewModel.clipDidFailToPlay(index)
true // Error handled
}
Notes
- Call this method when clip playback fails for any reason
- The SDK will display an error state for the clip
- Consider showing a user-friendly error message
- Network errors, codec issues, and missing clips should all trigger this
- The SDK may attempt to recover or suggest alternatives
Related Methods
- didStartPlayingClip() - Notify when clip starts playing
- didStopPlayingClip() - Notify when clip stops playing
- playClip() - SDK requests clip playback