Skip to main content

Configuration

This document covers the most common configuration options for VP Audio Player. The following sections are covered:

  • Audio details
  • Player size
  • Layout grid
  • Podcast mode
  • Floating player
  • Autostart and autopause on viewable
  • Audio locking

Audio details

You can set up the audio metadata, which the player uses to render the title, author, thumbnail, and other UI elements. Several properties have aliases so the same audio object can be reused across different VP players.

vpAudioPlayer("audio-details").setup({
audio: {
audioId: "",
file: "the_audio_file_path",
thumbnail: "",
title: "",
author: "",
duration: 0,
season: -1,
episode: -1,
}
});
PROPERTYDESCRIPTION
audio ObjectThis object contains all of the audio metadata properties shown below.
audioId stringThe unique ID of the audio. Alias: mediaId.
file stringThe URL of the audio file or HLS stream (mp3, m3u8). Alias: hlsUrl.
thumbnail stringThe URL of an image used as the cover art for the audio. Alias: thumbnailUrl.
title stringThe title of the audio.
author stringThe author or creator of the audio.
duration intThe duration of the audio in seconds.
season intThe season number (for podcast-style content). Use -1 when not applicable.
episode intThe episode number (for podcast-style content). Use -1 when not applicable.
advertising booleanA boolean indicating whether ads are enabled for the audio. See Advertising for details.

Player size

The VP Audio Player can be rendered either responsively (filling its container) or with a fixed width.

vpAudioPlayer("audio-player-responsive").setup({
audio: {
file: "the_audio_file_path"
},
config: {
size: {
responsive: true,
width: 0,
},
}
});

vpAudioPlayer("audio-player-fixed").setup({
audio: {
file: "the_audio_file_path"
},
config: {
size: {
responsive: false,
width: 480,
},
}
});
PROPERTYDESCRIPTION
size ObjectAn object that controls the rendered size of the player.
responsive booleanWhen true, the player fills its container width. When false, the player uses the value defined in width.
width numberAn integer specifying the fixed width of the player in pixels. Ignored when responsive is true.

Layout grid

The audio player uses a 9-cell grid layout that places the thumbnail, text (title/author), and controls. Two arrangements (default and alternate) are defined per breakpoint, and startWith chooses which one is shown initially. A user toggle (the collapse button) lets the user switch between them at runtime.

vpAudioPlayer("audio-grid").setup({
audio: {
file: "the_audio_file_path"
},
config: {
gridOptions: {
desktop: {
startWith: "default",
default: {
thumbnail: [1, 4, 7],
text: [2, 3, 5, 6],
controls: [8, 9],
},
alternate: {
thumbnail: [1, 2, 3],
text: [4, 5, 6],
controls: [7, 8, 9],
},
},
mobile: {
startWith: "default",
default: {
thumbnail: [1, 4],
text: [2, 3, 5, 6],
controls: [7, 8, 9],
},
alternate: {
thumbnail: [1, 2, 3],
text: [4, 5, 6],
controls: [7, 8, 9],
},
},
},
}
});
PROPERTYDESCRIPTION
gridOptions ObjectConfigures the player's grid layout for desktop and mobile breakpoints.
desktop ObjectGrid configuration applied on desktop viewports.
mobile ObjectGrid configuration applied on mobile viewports.
startWith stringWhich arrangement to render initially. Possible values: "default", "alternate".
default ObjectThe default grid arrangement, specifying which cells (1–9) each player element occupies.
alternate ObjectThe alternate grid arrangement that the user can toggle into via the collapse button.
thumbnail array[int]Array of grid cell numbers (1–9) where the thumbnail should be placed.
text array[int]Array of grid cell numbers where the title and author text should be placed.
controls array[int]Array of grid cell numbers where the playback controls should be placed.

Podcast mode

The audio player supports a podcast mode that renders a podcast preview with a list of episodes. When podcast mode is active, the player exposes an episode list and the podcast's metadata.

vpAudioPlayer("audio-podcast").setup({
audio: {
file: "the_audio_file_path",
podcast: {
state: true,
thumbnail: "",
title: "",
author: "",
id: "",
audios: [],
},
},
config: {
showPodcastPreview: true,
}
});
PROPERTYDESCRIPTION
podcast ObjectAn object that configures podcast mode for the audio.
state booleanWhen true, the audio is treated as part of a podcast and the podcast UI is enabled.
thumbnail stringThe URL of an image used as the podcast cover art.
title stringThe title of the podcast.
author stringThe author or producer of the podcast.
id stringAllows the use of a podcast which has already been created on vpPlayer admin (takes priority over the audios array).
audios array[Object]An array of audio objects representing the podcast episodes.
showPodcastPreview booleanControls whether the podcast preview UI is displayed. Configured on the config object.

Floating player

The float property allows the player to switch into a floating overlay when scrolled out of view, similar to the video player.

vpAudioPlayer("audio-float").setup({
audio: {
file: "the_audio_file_path"
},
config: {
float: {
state: true,
onMobile: false,
position: "BOTTOM_RIGHT",
dismissible: true,
requiresInteraction: false,
toVideoThreshold: 0.35,
toFloatThreshold: 0.2,
},
}
});
PROPERTYDESCRIPTION
float ObjectAn object that configures the floating player behavior.
state booleanEnables the floating player when true.
onMobile booleanEnables the floating player on mobile devices when true.
position stringPosition of the floating player. Possible values: "BOTTOM_RIGHT", "BOTTOM_LEFT", "TOP_RIGHT", "TOP_LEFT".
dismissible booleanWhen true, the floating player shows a close button that the user can use to dismiss it.
requiresInteraction booleanWhen true, the player must have been interacted with before it can switch to floating mode.
toFloatThreshold floatViewport visibility ratio (0–1) at which the player switches into the floating state.
toVideoThreshold floatViewport visibility ratio (0–1) at which the player switches back out of the floating state.

Autostart and autopause on viewable

The autostartOnViewable and autopauseOnViewable options let the player start or pause based on whether it is in the viewport.

vpAudioPlayer("audio-viewable").setup({
audio: {
file: "the_audio_file_path"
},
config: {
autostartOnViewable: {
state: false,
onMobile: false,
onData: false,
percentageViewable: 0.5,
},
autopauseOnViewable: {
state: false,
percentageViewable: 0.5,
},
}
});
PROPERTYDESCRIPTION
autostartOnViewable ObjectStarts playback automatically when the player becomes viewable.
state booleanEnables the autostart-on-viewable behavior when true.
onMobile booleanWhen true, the autostart-on-viewable behavior also applies on mobile devices.
onData booleanWhen true, the autostart-on-viewable behavior also applies on cellular data connections.
percentageViewable floatThe viewport visibility ratio (0–1) at which autostart should trigger.
autopauseOnViewable ObjectPauses playback automatically when the player scrolls out of view.
state booleanEnables the autopause-on-viewable behavior when true.
percentageViewable floatThe viewport visibility ratio (0–1) below which autopause should trigger.

Audio locking

The audioLocking option allows you to gate part of the audio behind a lock that triggers either after a number of seconds or at a percentage of playback. When the lock is activated, an alternate audio file can be played to communicate the paywall message.

vpAudioPlayer("audio-locking").setup({
audio: {
file: "the_audio_file_path",
audioLocking: {
isEnabled: false,
type: "seconds",
value: 15,
afterLockAudio: "",
},
}
});
PROPERTYDESCRIPTION
audioLocking ObjectAn object that configures audio locking behavior.
isEnabled booleanWhen true, audio locking is active for the audio.
type stringDetermines how the lock activation timing is measured. Possible values: "seconds", "percentage".
value numberThe activation timing value. If type is "seconds", this is the elapsed time at which the lock activates. If type is "percentage", this is the percentage of the audio that has been played at which the lock activates.
afterLockAudio stringThe URL of an audio file to play after the lock has been activated.

General configuration options

The following top-level config properties control general player behavior:

PROPERTYDESCRIPTION
autoplay booleanWhen true, the player begins playback automatically after setup.
loop booleanWhen true, playback restarts when the audio reaches the end.
casting booleanEnables Chromecast and AirPlay support when true.
skipAmount intThe number of seconds the skip-forward and skip-back buttons jump.
playbackRates array[float]Available playback speeds in the settings menu (e.g., [0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2]).
socialMedia array[string]An array of social media platforms that appear in the share menu (e.g., "FACEBOOK", "LINKEDIN", "REDDIT"). Sharing is hidden if the array is empty.
showPlaylist booleanWhen true, the playlist panel is shown from the start.
showPlaylistItemProgress booleanWhen true, the playlist items display their individual playback progress.
paginationTake intThe number of items loaded per playlist page.
pauseOtherAudios booleanWhen true, starting playback on this player pauses every other VP Audio Player on the page.
thumbnail booleanWhen true, the audio thumbnail is rendered in the player.
theme stringThe player theme. Leave empty for the default theme, or set to "minimal" for the minimal theme.
font ObjectAn object with family and url properties that configures the font used by the player UI.