onKeyPlayFocusChanged
Notifies the SDK that the key play with the specified index needs to gain focus.
Overview
Call this method when you want the SDK to focus on a specific key play in the panel. This can be used to highlight a particular clip, scroll to it in the list, or ensure it's visible to the user. The SDK will update its UI to bring the specified key play into focus.
Syntax
abstract fun onKeyPlayFocusChanged(index: Int)
Parameters
| Parameter | Type | Description |
|---|---|---|
index | Int | The index of the key play that should gain focus |
Example
// Request focus on a specific key play
fun focusKeyPlay(index: Int) {
viewModel.onKeyPlayFocusChanged(index)
}
// Focus on currently playing clip
fun focusCurrentClip() {
val currentIndex = getCurrentPlayingClipIndex()
viewModel.onKeyPlayFocusChanged(currentIndex)
}
// Focus on the first key play
fun focusFirstKeyPlay() {
viewModel.onKeyPlayFocusChanged(0)
}
// Focus on a key play based on user selection
fun onUserSelectedKeyPlay(index: Int) {
// Focus the key play
viewModel.onKeyPlayFocusChanged(index)
// Optionally start playback
playClip(index, null)
}
// Focus on next key play
fun focusNextKeyPlay() {
val currentIndex = getCurrentFocusedIndex()
val totalKeyPlays = getTotalKeyPlaysCount()
if (currentIndex < totalKeyPlays - 1) {
viewModel.onKeyPlayFocusChanged(currentIndex + 1)
}
}
Notes
- The SDK will scroll or highlight the specified key play
- Use this to synchronize focus between your app and the panel
- The index should be valid (within the range of available key plays)
- This is useful for keyboard navigation or deep linking to specific clips
Related Methods
- didStartPlayingClip() - Notify when clip starts playing
- playClip() - SDK requests clip playback