Audio Clip

The Audio Clip module allows for playback of audio content in various formats. As an extension of the Clip class, the Audio Clip provides access to shared properties, enabling you to leverage the same features and methods as other clip types.

Unlike other clip types, audio clips do not support customization through styles, so you won't be able to alter their visual appearance.

Example

Here's an example of how to work with an Audio Clip:

1. To add an audio file to your composition, first upload it to the library using:

const audioMediaId = await engine
  .getLibrary()
  .addMedia("https://example.com/path/to/your/audio/file.mp3");

Note that this action returns a unique identifier for the uploaded asset, which can be reused across multiple clips.

In the example above, we imported the media from a URL. However, you can also use a File object, a URL, or a UInt8Array, providing flexibility in how you source your media.

2. By default, uploading an asset doesn't display it immediately. To play your audio clip in a layer, create a new layer and add the clip using:

const audioLayer = engine.getTimeline().createLayer();
 
const audioClip = audioLayer.addClip({
  mediaDataId: audioMediaId,
  startTime: 0,
});

3. Once you've added your audio clip to a layer, you can retrieve its duration using:

const duration = clip.getDuration();

Supported Formats

Here is the list of all the supported formats:

FormatSupport
MP3
M4A
OGG
WAV
ACC

To learn more about the AudioClip, its properties, and functions, visit the API Reference.