/* * Copyright 2025 New Vector Ltd. * * SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial * Please see LICENSE files in the repository root for full details. */ import React, { type HTMLAttributes, type JSX, type MouseEventHandler } from "react"; import { IconButton } from "@vector-im/compound-web"; import Play from "@vector-im/compound-design-tokens/assets/web/icons/play-solid"; import Pause from "@vector-im/compound-design-tokens/assets/web/icons/pause-solid"; import styles from "./PlayPauseButton.module.css"; import { _t } from "../../utils/i18n"; export interface PlayPauseButtonProps extends HTMLAttributes { /** * Whether the button is disabled. * @default false */ disabled?: boolean; /** * Whether the audio is currently playing. * @default false */ playing?: boolean; /** * Function to toggle play/pause state. */ togglePlay: MouseEventHandler; } /** * A button component that toggles between play and pause states for audio playback. * * @example * ```tsx * {}} /> * ``` */ export function PlayPauseButton({ disabled = false, playing = false, togglePlay, ...rest }: Readonly): JSX.Element { const label = playing ? _t("action|pause") : _t("action|play"); return ( {playing ? : } ); }