observeProperty method

Future<void> observeProperty(
  1. String property,
  2. Future<void> listener(
    1. String
    )
)

Observes property for the internal libmpv instance of this Player. Please use this method only if you know what you are doing, existing methods in Player implementation are suited for the most use cases.

See:

Implementation

Future<void> observeProperty(
  String property,
  Future<void> Function(String) listener,
) async {
  if (disposed) {
    throw AssertionError('[Player] has been disposed');
  }
  await waitForPlayerInitialization;
  await waitForVideoControllerInitializationIfAttached;

  if (observed.containsKey(property)) {
    throw ArgumentError.value(
      property,
      'property',
      'Already observed',
    );
  }
  final reply = property.hashCode;
  observed[property] = listener;
  final name = property.toNativeUtf8();
  mpv.mpv_observe_property(
    ctx,
    reply,
    name.cast(),
    generated.mpv_format.MPV_FORMAT_NONE,
  );
  calloc.free(name);
}