Skip to content
DocumentationComponentsAudioPlayerProvider
ConfigurationInteractive playground

AudioPlayerProvider

Keep an audio session across page changes.

Preparing the playground…
Text and Markdown example
AudioPlayerProvider · Example
1function Example() { 2 function Controls() { 3 const { close } = useAudioPlayer(); 4 return <Button variant="outline" onClick={close}>Close audio session</Button>; 5 } 6 return <AudioPlayerProvider><Controls /></AudioPlayerProvider>; 7}
Read documentation in Markdown

How to use it

Mount it in a persistent layout. useAudioPlayer returns play and close to control the session from descendants.

To start audio, call play({ id: "track", src: "/audio.mp3", type: "audio", title: "My track" }) with an existing file. The provider must sit above pages that share playback.

Import

React / Next.js
1import { AudioPlayerProvider } from "@kivora/nextjs";

Interactive examples run inside a component with "use client". The playground's Copy button includes the imports needed for the current example.

API reference 0.2.0

Types from the installed published version, including component properties and common HTML attributes. “Optional” does not imply a default value; omitting a property lets the component decide.

PropertyTypeDescription
activeQueueIdstringConfigures activeQueueId. The type describes the supported values and structure.
aria-labelstringAccessible name of the control.
childrenReactNodeContent or child elements of the component.
classNamestringAdditional CSS classes to customize the element.
controlsVariant"standard" | "compact" | "cinema" | "series"Presentation of player controls.
defaultCheckedbooleanInitial selection of the control.
defaultValuestring | number | readonly string[]Initial value when the component manages its own state.
idstringElement identifier; associates labels and descriptions.
localestringLocalization in the format expected by the component.
messagesPartial<{ play: string; pause: string; seek: string; volume: string; mute: string; unmute: string; fullscreen: string; exitFullscreen: string; pip: string; settings: string; quality: string; audio: string; subtitles: string; speed: string; auto: string; off: string; live: string; goLive: string; loading: string; splash: string; ad: string; containsAds: string; skipAd: string; error: string; retry: string; download: string; cancelDownload: string; downloads: string; remove: string; playOffline: string; downloading: string; close: string; expand: string; collapse: string; exportFile: string; emptyDownloads: string; expired: string; back: string; forward: string; downloadError: string; actionError: string; upNext: string; nowPlaying: string; episodes: string; previous: string; next: string; }>Localized messages replacing the defaults.
mutedbooleanStart or keep playback muted.
onChangeChangeEventHandler<HTMLDivElement, Element>Change event. Check the type: some controls return an object, others a DOM event.
onClickMouseEventHandler<HTMLDivElement>Action performed when the element is activated.
onQueueSelect((item: PlayerQueueItem) => void)Callback for this event. The signature describes its arguments.
onSubmitSubmitEventHandler<HTMLDivElement>Form submission event.
optionsPlayerControllerOptionsComponent options or configuration. See the type structure.
overlaysPlayerOverlay[]Configures overlays. The type describes the supported values and structure.
presentation"footer" | "inline" | "sheet"Audio players can live in the footer and expand into a bottom sheet.
programPlayerProgramConfigures program. The type describes the supported values and structure.
queuePlayerQueueItem[]Configures queue. The type describes the supported values and structure.
roleAriaRoleSemantic role of the element. Keep the default role unless a change is justified.
settingsLayout"list" | "tabs"Mobile settings presentation; list preserves the previous layout.
styleCSSPropertiesReact inline styles.
tabIndexnumberKeyboard focus order and availability.
titlestringTitle or supplementary information.

TypeScript definition

Review each component's properties and published declaration. Native and accessibility attributes are inherited from the element specified by its type.

AudioPlayerProvider25 properties
AudioPlayerProvider · TypeScript
1declare function AudioPlayerProvider({ children, ...props }: React.PropsWithChildren<Omit<PlayerProps, 'source' | 'controller' | 'autoPlay'>>): React.JSX.Element;
API generated from @kivora/nextjs 0.2.0View package