WebByteArkPlayerBackend constructor

WebByteArkPlayerBackend(
  1. String playerId, {
  2. void onEvent(
    1. ByteArkPlayerNativeEvent event
    )?,
  3. void onError(
    1. ByteArkPlayerPlaybackErrorData error
    )?,
})

Creates a backend for the Player identified by playerId.

The onEvent callback receives every Player event after JS-side translation, including ad lifecycle events and error events. The controller passes its _dispatchEvent method here. Calls are already micro-tasked when they reach onEvent — implementations may treat them as fully async.

The onError callback is invoked whenever a JS exception is caught inside an action method (play / pause / dispose). When omitted (e.g. during scaffolding tests), errors fall through to debugPrint.

Implementation

WebByteArkPlayerBackend(
  this.playerId, {
  void Function(ByteArkPlayerNativeEvent event)? onEvent,
  void Function(ByteArkPlayerPlaybackErrorData error)? onError,
})  : _onEvent = onEvent,
      _onError = onError;