attachViewId method

void attachViewId(
  1. int id
)

Bind the controller to a platform view id.

Implementation

void attachViewId(int id) {
  _channel = MethodChannel('thaplayer/view_$id');
  // Rebind events; dispose previous to avoid leaks
  _events?.dispose();
  final ev = ThaNativeEvents(id);
  ev.start();
  _events = ev;
  _eventsListener?.call();
  _eventsListener = () {
    final v = ev.state.value;
    _resumePositionMs = v.position.inMilliseconds;
    _wasPlaying = v.isPlaying;
  };
  ev.state.addListener(_eventsListener!);
}