registerHotKeys method

Future<void> registerHotKeys()

Implementation

Future<void> registerHotKeys() async {
  if (HotKeyManager.instance.registeredHotKeyList.length == 0) {
    HotKey arrowUP = HotKey(
      KeyCode.arrowUp,
      scope: HotKeyScope.inapp,
    );
    HotKey arrowDown = HotKey(
      KeyCode.arrowDown,
      scope: HotKeyScope.inapp,
    );
    HotKey arrowRight = HotKey(
      KeyCode.arrowRight,
      scope: HotKeyScope.inapp,
    );
    HotKey arrowLeft = HotKey(
      KeyCode.arrowLeft,
      scope: HotKeyScope.inapp,
    );
    HotKey escape = HotKey(
      KeyCode.escape,
      scope: HotKeyScope.inapp,
    );
    HotKey enter = HotKey(
      KeyCode.enter,
      scope: HotKeyScope.inapp,
    );
    HotKey spaceBar = HotKey(
      KeyCode.space,
      scope: HotKeyScope.inapp,
    );
    HotKey dot = HotKey(
      KeyCode.numpadDecimal,
      scope: HotKeyScope.inapp,
    );
    await HotKeyManager.instance.register(
      arrowUP,
      keyDownHandler: (hotKey) {
        print('onKeyDown+${hotKey.toJson()}');
        setVolume(volume.value + 0.05);
      },
    );
    await HotKeyManager.instance.register(
      arrowDown,
      keyDownHandler: (hotKey) {
        print('onKeyDown+${hotKey.toJson()}');
        setVolume(volume.value - 0.05);
      },
    );
    await HotKeyManager.instance.register(
      arrowRight,
      keyDownHandler: (hotKey) {
        print('onKeyDown+${hotKey.toJson()}');
        seekTo(position.value + Duration(seconds: 5));
      },
    );
    await HotKeyManager.instance.register(
      arrowLeft,
      keyDownHandler: (hotKey) {
        print('onKeyDown+${hotKey.toJson()}');
        seekTo(position.value - Duration(seconds: 5));
      },
    );

    await HotKeyManager.instance.register(
      escape,
      keyDownHandler: (hotKey) {
        print('onKeyDown+${hotKey.toJson()}');
        screenManager.setWindowsFullScreen(false, this);
      },
    );
    await HotKeyManager.instance.register(
      enter,
      keyDownHandler: (hotKey) {
        print('onKeyDown+${hotKey.toJson()}');
        screenManager.setWindowsFullScreen(!_fullscreen.value, this);
      },
    );
    await HotKeyManager.instance.register(
      spaceBar,
      keyDownHandler: (hotKey) {
        print('onKeyDown+${hotKey.toJson()}');
        if (playerStatus.playing) {
          pause();
        } else {
          play();
        }
      },
    );
    await HotKeyManager.instance.register(
      dot,
      keyDownHandler: (hotKey) {
        toggleVideoFit();
      },
    );
  } else {
    print("hotkeys are registered ");
  }
  //await HotKeyManager.instance.unregister(_hotKey);
}