handleMethodCall method

  1. @override
Future<DBusMethodResponse> handleMethodCall(
  1. DBusMethodCall methodCall
)

Called when a method call is received on this object.

Implementation

@override
Future<DBusMethodResponse> handleMethodCall(DBusMethodCall methodCall) async {
  if (methodCall.interface == 'org.mpris.MediaPlayer2') {
    if (methodCall.name == 'Raise') {
      if (methodCall.values.isNotEmpty) {
        return DBusMethodErrorResponse.invalidArgs();
      }
      return doRaise();
    } else if (methodCall.name == 'Quit') {
      if (methodCall.values.isNotEmpty) {
        return DBusMethodErrorResponse.invalidArgs();
      }
      return doQuit();
    } else {
      return DBusMethodErrorResponse.unknownMethod();
    }
  } else if (methodCall.interface == 'org.mpris.MediaPlayer2.Player') {
    if (methodCall.name == 'Next') {
      if (methodCall.values.isNotEmpty) {
        return DBusMethodErrorResponse.invalidArgs();
      }
      return doNext();
    } else if (methodCall.name == 'Previous') {
      if (methodCall.values.isNotEmpty) {
        return DBusMethodErrorResponse.invalidArgs();
      }
      return doPrevious();
    } else if (methodCall.name == 'Pause') {
      if (methodCall.values.isNotEmpty) {
        return DBusMethodErrorResponse.invalidArgs();
      }
      return doPause();
    } else if (methodCall.name == 'PlayPause') {
      if (methodCall.values.isNotEmpty) {
        return DBusMethodErrorResponse.invalidArgs();
      }
      return doPlayPause();
    } else if (methodCall.name == 'Stop') {
      if (methodCall.values.isNotEmpty) {
        return DBusMethodErrorResponse.invalidArgs();
      }
      return doStop();
    } else if (methodCall.name == 'Play') {
      if (methodCall.values.isNotEmpty) {
        return DBusMethodErrorResponse.invalidArgs();
      }
      return doPlay();
    } else if (methodCall.name == 'Seek') {
      if (methodCall.signature != DBusSignature('x')) {
        return DBusMethodErrorResponse.invalidArgs();
      }
      return doSeek(methodCall.values[0].asInt64());
    } else if (methodCall.name == 'SetPosition') {
      if (methodCall.signature != DBusSignature('ox')) {
        return DBusMethodErrorResponse.invalidArgs();
      }
      return doSetPosition(methodCall.values[0].asObjectPath().toString(),
          methodCall.values[1].asInt64());
    } else if (methodCall.name == 'OpenUri') {
      if (methodCall.signature != DBusSignature('s')) {
        return DBusMethodErrorResponse.invalidArgs();
      }
      return doOpenUri(methodCall.values[0].asString());
    } else {
      return DBusMethodErrorResponse.unknownMethod();
    }
  } else {
    return DBusMethodErrorResponse.unknownInterface();
  }
}