Vivid API

Audio Player

Audio Player is a component used to play audio files. It is based on the HTML5 audio element.

Usage

import { registerAudioPlayer } from '@vonage/vivid-api';
registerAudioPlayer('your-prefix');

Audio Source

Use the src attribute to add an audio track to the Audio Player.

Current Time

Use the currentTime property change or get the Audio Player’s current time. The property accepts and returns a number representing the time in seconds.

Duration

The duration property indicates the duration of the loaded audio. The property is read only and returns a number representing the time in seconds.

Duration Fallback

The duration-fallback attribute enables fallback logic to fetch and decode audio buffer for duration when metadata is missing.

Paused

The paused property indicates if the player is currently paused or not. The property is read only and returns a boolean value.

Play and Pause Methods

The audio can be played and paused programatically using the play() and pause() methods.

Styles

Inline Size (Width)

By default, Audio Player’s max-inline-size is100%. You can specify a different value with setting max-inline-size on the vwc-audio-player.

API Reference

Properties

PropertyTypeDefaultDescription
connotation'accent' | 'cta'Sets the color of the audio player
currentTimenumber
disabledbooleanSets the disabled state of the audio player
durationnumber
durationFallbackbooleanEnables fallback logic to fetch and decode audio buffer for duration when metadata is missing.
notimebooleanHides the time stamp
pauseButtonAriaLabelstring
pausedboolean
playButtonAriaLabelstring
playbackRatenumber
playbackRatesstringComma-separated string of numbers to define playback speeds
skipBackwardButtonAriaLabelstring
skipBy'0' | '5' | '10' | '30'Allows the audio to skip back or forward
skipForwardButtonAriaLabelstring
sliderAriaLabelstring
srcstringSets the audio source URL
PropertyTypeDefaultDescription
connotation'accent' | 'cta'Sets the color of the audio player
currentTime
(property only)
number
disabledbooleanSets the disabled state of the audio player
duration
(property only)
number
duration-fallbackbooleanEnables fallback logic to fetch and decode audio buffer for duration when metadata is missing.
notimebooleanHides the time stamp
pause-button-aria-labelstring
paused
(property only)
boolean
play-button-aria-labelstring
playbackRate
(property only)
number
playback-ratesstringComma-separated string of numbers to define playback speeds
skip-backward-aria-labelstring
skip-by'0' | '5' | '10' | '30'Allows the audio to skip back or forward
skip-forward-aria-labelstring
slider-aria-labelstring
srcstringSets the audio source URL

Events

NameTypeDescription
pauseCustomEvent<undefined>Fires when the audio playback is paused.
playCustomEvent<undefined>Fires when the audio playback is started.
NameTypeDescription
pauseCustomEvent<undefined>Fires when the audio playback is paused.
playCustomEvent<undefined>Fires when the audio playback is started.

Methods

NameParamsReturnsDescription
pausevoid
playvoid