> ## 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.

# Next Segment Button

> Jumps to the next segment and emits a user interaction event.

export const NextSegmentButtonDemo = () => {
  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);
  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="Next segment" onClick={() => {
    player.onEvent(newEvent({
      type: "PressedNextSegment",
      description: "The next segment button was pressed."
    }));
  }}>
          <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="currentColor" aria-hidden="true">
            <path fillRule="evenodd" d="M4.6 8.08 Q3.55 7.5 3.55 8.7 L3.55 15.3 Q3.55 16.5 4.6 15.92 L10.39 12.73 Q11.7 12 10.39 11.27ZM15.15 7.3h4.25a1.05 1.05 0 0 1 0 2.1h-4.25a1.05 1.05 0 0 1 0 -2.1ZM15.15 10.95h4.25a1.05 1.05 0 0 1 0 2.1h-4.25a1.05 1.05 0 0 1 0 -2.1ZM15.15 14.6h4.25a1.05 1.05 0 0 1 0 2.1h-4.25a1.05 1.05 0 0 1 0 -2.1Z" />
          </svg>
        </button>}
    </div>;
};

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

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

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

    export function NextSegmentButton() {
      const player = usePlayer();
      return (
        <button
          type="button"
          aria-label="Next segment"
          onClick={() => {
            player.onEvent(
              newEvent({
                type: "PressedNextSegment",
                description: "The next segment button was pressed.",
              }),
            );
          }}
        >
          <NextSegmentIcon size={24} />
        </button>
      );
    }
    ```
  </Tab>
</Tabs>

## Installation

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

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

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

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

## Usage

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

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

On click, the button emits a `PressedNextSegment` event on the surrounding
[`PlayerProvider`](/player-ui/react/player-provider), built with
[`newEvent`](/player-ui/react/new-event). The player handles the event and moves
playback to the next segment.

## Reference

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