JFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr{ gilour

File "use-player-click-handler.ts"

Full Path: /home/markqprx/iniasli.pro/client/player/hooks/use-player-click-handler.ts
File size: 734 bytes
MIME-type: text/plain
Charset: utf-8

import {useCallback, useRef} from 'react';
import {usePlayerActions} from '@common/player/hooks/use-player-actions';

export function usePlayerClickHandler() {
  const clickRef = useRef(0);
  const player = usePlayerActions();

  const togglePlay = useCallback(() => {
    if (player.getState().isPlaying) {
      player.pause();
    } else {
      player.play();
    }
  }, [player]);

  return useCallback(() => {
    if (!player.getState().providerReady) return;
    clickRef.current += 1;
    togglePlay();
    if (clickRef.current === 1) {
      setTimeout(() => {
        if (clickRef.current > 1) {
          player.toggleFullscreen();
        }
        clickRef.current = 0;
      }, 300);
    }
  }, [player, togglePlay]);
}