Skip to content
Template Empire
Browse components

Audio Region Loop

A free React audio region loop for repeating a real passage with native playback.

Language workshop · pronunciation

Hear the sentence as one phrase.

Repeat the original line and notice where the stress falls. The player stays native; the loop only returns playback to this recorded passage.

Harbour sentence · spoken model

Passage: 0.00–2.20 seconds

Open original recording

Checking recording duration…

Transcript or description

At dawn, the bell answers across the harbour.

Instrument bench · resonance

Compare the ringing partials.

A struck-string reference for listening tests. This nonverbal recording is a locally generated three-part harmonic chord with a soft attack and decay.

Three-part resonance · reference tone

Passage: 1.00–4.00 seconds

Open original recording

Checking recording duration…

Transcript or description

Nonverbal audio: three sustained harmonic tones enter together, ring briefly, then fade to silence.

Customise

Code

<MediaAudioRegionLoop src="/media/pronunciation.wav" title="Harbour sentence · spoken model" transcript="At dawn, the bell answers across the harbour." regionStart={0} regionEnd={2.2} />

Audio Region Loop is a free React audio component for Next.js that returns native playback to one metadata-validated passage. A language learner can repeat a spoken phrase; a sound designer can listen again to a short original recording. The browser still owns the audio controls, and the visible transcript or nonverbal description remains available at every step.

The loop follows native media events rather than a frame clock. Browsers deliver those events at varying rates, so playback may pass the selected end slightly before it seeks back to the start; the component makes no sample-accurate promise. The native player, transcript and direct source link render before hydration, while the loop action appears only when the loaded recording contains the requested region. A failed source, invalid range, or rejected play request leaves ordinary media access intact.

Install

Add the @te registry to your components.json once:

{
  "registries": {
    "@te": "https://templateempire.io/r/{name}.json"
  }
}

Then install the component:

npx shadcn@latest add @te/media-audio-region-loop

Usage

import { MediaAudioRegionLoop } from "@/components/media-audio-region-loop";

export default function Page() {
  return (
    <MediaAudioRegionLoop
      src="/media/pronunciation.wav"
      title="Harbour sentence · spoken model"
      transcript="At dawn, the bell answers across the harbour."
      regionStart={0}
      regionEnd={2.2}
    />
  );
}

Props

PropTypeDefaultDescription
srcstringrequiredConsumer-owned audio URL. No microphone or streaming client is used.
titlestringrequiredSpecific visible title for the recording.
transcriptstringrequiredComplete transcript, or an accurate description for nonverbal audio.
regionStartnumberrequiredFinite, non-negative start time in seconds.
regionEndnumberrequiredFinite end time in seconds, greater than the start and no later than the loaded duration.
classNamestringundefinedAdditional classes merged onto the section with cn().

Customisation

The component exposes one accent and one track token so consumers can align the passage controls with their theme. Native audio controls keep their browser-provided appearance and semantics.

:root {
  --audio-region-ink: var(--primary);
  --audio-region-track: var(--border);
}

Frequently asked questions

Does the loop stop exactly at the region end?
No. The component reacts to native media events, whose cadence varies by browser and system. Playback can pass the marked end briefly before returning to the start; the component does not promise sample-accurate boundaries.
Does this replace the browser's player?
No. Native audio controls stay available for keyboard, assistive technology, volume and ordinary playback. The additional loop button only enables or stops returning to the requested passage.
What happens when the region or recording is invalid?
The loop control stays hidden with a visible explanation. The title, native player, supplied transcript or description and source link remain available.

Related components

Building a complete product page?Template Empire templates pair reusable interface components with complete product experiences.Explore Template Empire templates