Event Handling
How to subscribe to and process playback and ad-related events streamed from the native SDKs via the event channel.
Subscribe to native events (buffering, started, completed, ad events). You subscribe to events of all players, but can filter the wanted listeners by playerReference.
void listenForPlayerEvents() {
_player.handleAllPlayerEvents((event) {
String? playerEvent = event['event']; // Event dictionary key for player events
String? adEvent = event['ad']; // Event dictionary key for ad events
if (playerEvent != null) {
if (event['event'] == 'playerVideoLoad') {
/// Handle playerVideoLoad event
}
setState(() {
_eventLogs.add(
"${event['playerReference']}: $playerEvent");
Future.delayed(Duration(milliseconds: 100), () {
_scrollController.jumpTo(
_scrollController.position.maxScrollExtent);
});
});
}
});
}
Updated 18 days ago
What’s Next