Skip to main content

React

@javaabu/dhivehigpt-player/react provides a <DhivehiGPTPlayer> component wrapping AudioPlayer. Requires React 17+ as a peer dependency (not installed unless you import this subpath).

import { DhivehiGPTPlayer } from '@javaabu/dhivehigpt-player/react';

function Article() {
return (
<DhivehiGPTPlayer
src="https://example.com/article.mp3"
accent
sticky
onReady={(player) => console.log('ready', player)}
/>
);
}

Props

All player options (dark, accent, shadow, flush, showTime, showSpeed, showVolume, speeds, sticky, loadFont) are accepted as props, plus:

PropDescription
srcRequired. The audio URL.
onReadyCalled once with the underlying AudioPlayer instance.
classNameApplied to the wrapping <div>.
audioPropsExtra props forwarded to the hidden <audio> element (e.g. preload, crossOrigin).

Changing src or any option prop destroys and recreates the underlying player. The player is destroyed automatically on unmount.