> ## Documentation Index
> Fetch the complete documentation index at: https://docs.beyondwords.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Previous Seconds Button

> Seeks backward by a fixed number of seconds.

export const PrevSecondsButtonDemo = () => {
  const MOCK_CONTENT = [{
    id: "demo-1",
    title: "How AI voices are changing publishing",
    imageUrl: "/images/player-ui/demo-cover.svg",
    sourceUrl: "https://beyondwords.io",
    sourceId: "demo",
    adsEnabled: false,
    duration: 124,
    audio: [{
      id: "audio-1",
      url: "/images/player-ui/demo-silent.mp3",
      contentType: "audio/mpeg",
      duration: 124
    }],
    video: [],
    summarization: {
      audio: [],
      video: []
    },
    segments: []
  }];
  const newEvent = props => ({
    id: crypto.randomUUID(),
    createdAt: new Date().toISOString(),
    status: "pending",
    initiatedBy: "user",
    ...props
  });
  const [target, setTarget] = useState(null);
  const [player, setPlayer] = useState(null);
  const seconds = 10;
  useEffect(() => {
    if (!target) return;
    let instance;
    const init = () => {
      instance = new window.BeyondWords.Player({
        target,
        content: MOCK_CONTENT,
        widgetStyle: "none",
        showUserInterface: false,
        analyticsConsent: "none"
      });
      setPlayer(instance);
    };
    if (window.BeyondWords) init(); else window.addEventListener("BeyondWordsReady", init);
    return () => {
      window.removeEventListener("BeyondWordsReady", init);
      if (instance) instance.destroy();
    };
  }, [target]);
  return <div className="not-prose flex w-full items-center justify-center rounded-lg border p-10" style={{
    minHeight: "16rem",
    fontFamily: 'ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif'
  }}>
      <div ref={setTarget} style={{
    display: "none"
  }} />
      {player && <button type="button" aria-label={`Skip back ${seconds} seconds`} onClick={() => {
    player.onEvent(newEvent({
      type: "PressedSeekBack",
      description: "The seek backward button was pressed.",
      seconds
    }));
  }}>
          <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
            <path d="M7 9l-3 -3l3 -3" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" />
            <path d="M15.997 17.918a6.002 6.002 0 0 0 -.997 -11.918h-11" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" />
            <path d="M6 14v6" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" />
            <path d="M9 15.5v3a1.5 1.5 0 0 0 3 0v-3a1.5 1.5 0 0 0 -3 0" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" />
          </svg>
        </button>}
    </div>;
};

<Tabs>
  <Tab title="Preview">
    <PrevSecondsButtonDemo />
  </Tab>

  <Tab title="Code">
    ```jsx PrevSecondsButton.jsx theme={null}
    "use client";

    import { newEvent } from "@/lib/newEvent";
    import { SeekBackIcon } from "@/registry/react/Icons";
    import { usePlayer } from "@/registry/react/PlayerProvider";

    export function PrevSecondsButton({ seconds = 10 }) {
      const player = usePlayer();
      return (
        <button
          type="button"
          aria-label={`Skip back ${seconds} seconds`}
          onClick={() => {
            player.onEvent(
              newEvent({
                type: "PressedSeekBack",
                description: "The seek backward button was pressed.",
                seconds,
              }),
            );
          }}
        >
          <SeekBackIcon seconds={seconds} size={24} />
        </button>
      );
    }
    ```
  </Tab>
</Tabs>

## Installation

<CodeGroup>
  ```bash npm theme={null}
  npx @beyondwords/cli components add prev-seconds-button
  ```

  ```bash pnpm theme={null}
  pnpm dlx @beyondwords/cli components add prev-seconds-button
  ```

  ```bash yarn theme={null}
  yarn dlx @beyondwords/cli components add prev-seconds-button
  ```

  ```bash bun theme={null}
  bunx --bun @beyondwords/cli components add prev-seconds-button
  ```
</CodeGroup>

## Usage

```tsx theme={null}
import { PlayerProvider } from '@/registry/react/PlayerProvider';
import { PrevSecondsButton } from '@/registry/react/PrevSecondsButton';

export function Player() {
  return (
    <PlayerProvider args={{ projectId: 9504, contentId: "ba00ef51-03ac-4a85-8b98-e45c957e8ef8", showUserInterface: false }}>
      <PrevSecondsButton seconds={10} />
    </PlayerProvider>
  );
}
```

On click the button emits a `PressedSeekBack` event (built with
[`newEvent`](/player-ui/react/new-event)) carrying the number of `seconds` to seek,
on the surrounding [`PlayerProvider`](/player-ui/react/player-provider). The `seconds`
prop controls both the jump distance and the label, and defaults to `10`.

## Reference

|                       |                                                                 |
| --------------------- | --------------------------------------------------------------- |
| **Props**             | `seconds` (default `10`)                                        |
| **Player state read** | None                                                            |
| **Events emitted**    | `PressedSeekBack`                                               |
| **Requires**          | a [`PlayerProvider`](/player-ui/react/player-provider) ancestor |
