ReferenceMedia
Audio
Native audio playback that can provide media to a Video.js player
Import
Import Audio from the audio preset:
Anatomy
Use with a player
Place Audio anywhere inside an AudioPlayer, or inside another Video.js Player configured for audio. It becomes that player’s media provider automatically. Outside a player, Audio behaves as a standalone native <audio>.
Native behavior
Video.js does not replace the native audio API. Use src for one URL or add child <source> elements when the browser should choose between candidates. See Media sources when you need an HLS, Mux, Spotify, or other playback adapter.
Audio forwards native attributes, event handlers, and children to the underlying <audio>. See Refs for what ref and mediaRef receive.
See MDN for the complete <audio> element, HTMLAudioElement, and shared HTMLMediaElement APIs.
Examples
Basic Usage
This native audio element uses a child source and browser controls while providing media to the surrounding Video.js player.
API Reference
Props
Accepts the standard React props for a native <audio>: autoPlaycontrolscontrolsListcrossOriginloopmutedpreloadsrc
Audio also accepts children and common element props such as className and style, plus these Video.js-specific props:
Refs
ref
Forwards to the rendered <audio>, an HTMLAudioElement with its complete native property and method API.
mediaRef
Receives the same HTMLAudioElement as ref. Adapter-backed components such as HlsAudio and SpotifyAudio hand their playback adapter to mediaRef instead, so code that works with several media components can read the playback object from one prop.
Events
Accepts the standard React media event props: onAbortonCanPlayonCanPlayThroughonDurationChangeonEmptiedonEncryptedonEndedonErroronLoadedDataonLoadedMetadataonLoadStartonPauseonPlayonPlayingonProgressonRateChangeonSeekedonSeekingonStalledonSuspendonTimeUpdateonVolumeChangeonWaiting
The native waitingforkey event has no React prop. Attach a listener through the ref with addEventListener.