play-pause-yandex-triggers

add triggers to play/pause control
This commit is contained in:
gofnnp 2024-06-25 02:39:31 +04:00
parent 9f899518fd
commit 966716fd61

View File

@ -31,6 +31,12 @@ const PersonalVideo = React.memo<IPersonalVideoProps>(({ url, gender }) => {
metricService.reachGoal(EGoals.ROSE_VIDEO_PLAY_END); metricService.reachGoal(EGoals.ROSE_VIDEO_PLAY_END);
}; };
const handlePlayPause = () => {
setIsPlaying((prev) => !prev);
if (isPlaying) metricService.reachGoal(EGoals.ROSE_VIDEO_PLAY_USER_PLAY);
if (!isPlaying) metricService.reachGoal(EGoals.ROSE_VIDEO_PLAY_USER_STOP);
};
return ( return (
<div className={`${styles.container} ym-hide-content`}> <div className={`${styles.container} ym-hide-content`}>
{!isPlaying && !isError && !isStarted && ( {!isPlaying && !isError && !isStarted && (
@ -67,7 +73,7 @@ const PersonalVideo = React.memo<IPersonalVideoProps>(({ url, gender }) => {
{!isError && isStarted && ( {!isError && isStarted && (
<PlayPauseButton <PlayPauseButton
state={isPlaying ? "pause" : "play"} state={isPlaying ? "pause" : "play"}
onClick={() => setIsPlaying((prev) => !prev)} onClick={handlePlayPause}
className={styles["play-pause-button"]} className={styles["play-pause-button"]}
/> />
)} )}