Edit in GitHubLog an issue

Use Audio

Import audio into the page

Similarly to Images and Video, you can add Audio to the page using the addAudio() method of the addOnUISdk.app.document object, which expects a Blob object as the first argument, and a MediaAttribute object with the audio's title (mandatory) and author (optional) as the second.

Example

Copied to your clipboard
// sandbox/code.js
import addOnUISdk from "https://express.adobe.com/static/add-on-sdk/sdk.js";
addOnUISdk.ready.then(async () => {
try {
const audioUrl =
"https://www.nasa.gov/wp-content/uploads/static/history/alsj/a11/a11a1021133-3114.mp3";
const audio = await fetch(audioUrl);
const audioBlob = await audio.blob();
await addOnUISdk.app.document.addAudio(
audioBlob, // 👈 Blob object
{
title: "Apollo 11 - Lunar Landing",
author: "NASA",
}
);
} catch (e) {
console.error("Failed to add the audio", e);
}
});

Please note that you can use fetch() also to get videos that are local to the add-on; in this case, you can use paths relative to the add-on's root.

Copied to your clipboard
import addOnUISdk from "https://express.adobe.com/static/add-on-sdk/sdk.js";
addOnUISdk.ready.then(async () => {
try {
// 👇 Local audio
const audioUrl =
"https://www.nasa.gov/wp-content/uploads/static/history/alsj/a11/a11a1021133-3114.mp3";
const audio = await fetch(audioUrl);
// ... same as before

FAQs

Q: How do I add audio to a page?

A: Call addOnUISdk.app.document.addAudio(blob, attributes) with audio blob and MediaAttribute object.

Q: What parameters does addAudio require?

A: A Blob object and a MediaAttribute object with mandatory title and optional author properties.

Q: How do I get audio as a blob?

A: Use fetch(audioUrl).then(r => r.blob()) to convert audio files to blob format.

Q: Can I use local audio files?

A: Yes, use relative paths from add-on root with fetch() to load local audio files.

Q: What attributes are required for audio?

A: Title is mandatory, author is optional in the MediaAttribute object.

Q: Can I use remote audio URLs?

A: Yes, fetch remote audio URLs and convert to blob before adding to document.

Q: What audio formats are supported?

A: Refer to Adobe Express file format requirements page for supported audio formats and size limits.

Q: How do I handle audio loading errors?

A: Use try/catch blocks around fetch() and addAudio() calls to handle loading failures.

  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2025 Adobe. All rights reserved.