Event Interface
Introduction
The MaestroEventInterface defines methods for letting your app notify the SDK of certain events and control UI functionalities. This interface is implemented by MaestroEventViewModel.
Key Responsibilities
- Playback Control: Notify SDK of clip playback lifecycle events
- Panel Management: Notify SDK when panel visibility changes
- Overlay Management: Notify SDK when overlay visibility changes
- Focus Management: Request focus changes for key plays
- State Access: Access SDK state through reactive StateFlow properties
Methods Overview
Playback Controls
Methods for managing clip playback state.
| Method | Description |
|---|---|
| didStartPlayingClip() | Notifies SDK that a clip started playing |
| didStopPlayingClip() | Notifies SDK that a clip stopped playing |
| clipDidFailToPlay() | Notifies SDK that a clip failed to play |
| didUpdatePlaybackProgressOfClip() | Notifies SDK of clip playback progress |
Panel Management
Methods for managing panel visibility.
| Method | Description |
|---|---|
| didShowPanel() | Notifies SDK that the panel was displayed |
| didHidePanel() | Notifies SDK that the panel was hidden |
Focus Management
Methods for managing focus within the panel.
| Method | Description |
|---|---|
| onKeyPlayFocusChanged() | Notifies SDK that a key play needs to gain focus |
Usage Example
@Composable
fun MaestroScreen(sdk: MaestroSDK.Instance) {
val viewModel = maestroEventViewModel(sdk)
// Notify SDK of playback events
VideoPlayer(
onPlaybackStarted = { index ->
viewModel.didStartPlayingClip(index)
},
onPlaybackStopped = { index ->
viewModel.didStopPlayingClip(index)
},
onPlaybackProgress = { progress ->
viewModel.didUpdatePlaybackProgressOfClip(progress)
},
onPlaybackFailed = { index ->
viewModel.clipDidFailToPlay(index)
}
)
// Notify SDK of panel visibility
var isPanelVisible by remember { mutableStateOf(false) }
if (isPanelVisible) {
MaestroPanel(maestroEventViewModel = viewModel)
LaunchedEffect(Unit) {
viewModel.didShowPanel(MaestroPanelType.Chat)
}
} else {
LaunchedEffect(Unit) {
viewModel.didHidePanel()
}
}
}