A beautiful audio player for MP3 and M4B formats with track switching.
import dynamic from "next/dynamic";
const AudioReader = dynamic(
() => import("epub-pdf-viewer").then((mod) => mod.AudioReader),
{ ssr: false }
);
export default function MyAudioBook() {
const tracks = [
{ title: "Chapter 1", author: "Author Name", url: "/audio1.mp3" },
{ title: "Chapter 2", author: "Author Name", url: "/audio2.m4b" }
];
return (
<AudioReader
tracks={tracks}
bookName="My Audio Book"
themeColor="#10b981"
toast={toast} // Optional for notifications
/>
);
}| Prop Name | Type | Required | Description |
|---|---|---|---|
| tracks | Array | Yes | Array of objects `title, author, url` for the playlist. |
| activeTrackIndex | number | No | The index of the track to play. Default: 0. |
| onTrackSelect | function | No | Callback when track changes `(track, index) => void`. |
| bookName | string | No | The overall title of the audiobook. |
| themeColor | string | No | Hex color for accents and UI elements. |
| coverUrl | string | No | Cover image URL for the vinyl disc art. |
| toast | object | No | Toast notification object (e.g. `sonner`). |