AudioPlay allows you to incorporate music, sound effects, voiceovers, or any other audio content into your video projects.

Properties

PropertyTypeDefaultDescription
idstringuuid()A unique identifier for the AudioPlay.
urlstring-The URL of the audio file
namestring-A short name for the audio track
startTimenumber0The time (in seconds) when the audio begins
endTimenumber-The time (in seconds) when the audio ends
volumenumber1The volume level of the audio track (0 to 1)
fadeobjectnull(Optional) The fade in and fade out in seconds

Usage

Here’s an example of how to create and add an AudioPlay object to a clip:

import BlendDuck, { Clip, AudioPlay } from "@blendduck/node-sdk";

// Create a new clip
const clip = new Clip(10); // 10-second clip

// Create an audio track
const backgroundMusic = new AudioPlay({
  url: "https://s.blendduck.com/audios/motivation.mp3",
  name: "Background Music",
  startTime: 0,
  endTime: 10,
  volume: 0.8
});

// Add the audio track to the clip
clip.addAudioPlay(backgroundMusic);

You can create smooth fades in and out by fade properties

const backgroundMusic = new AudioPlay({
  url: "https://s.blendduck.com/audios/motivation.mp3",
  name: "Background Music",
  startTime: 0,
  endTime: 10,
  volume: 0.8,
  fade: {
    in: 2, // fade in at the beginning for 2 seconds
    out: 3, // fade out at the end for 3 seconds
  }
});