attachPlayer method
Attaches the JS player instance once the view factory has constructed it. Called exactly once per backend; subsequent calls overwrite the reference (used when the platform view recreates after a hot reload). Also wires every JS event listener required for Listener-callback delivery, then drains any controller calls that arrived while the JS player was still being constructed.
Implementation
void attachPlayer(ByteArkPlayerWebJs player) {
_player = player;
_wireEvents(player);
if (_pendingActions.isNotEmpty) {
final queue = List<_PendingAction>.from(_pendingActions);
_pendingActions.clear();
for (final pending in queue) {
try {
pending.action(player);
} catch (e) {
_reportError(pending.op, e);
}
}
}
}