Library

The Library is where all your assets come together. This gallery stores images, audio, video files and subtitles making it easy to manage your media library.

One key aspect of the Library is that multiple clips can reference the same media asset. For example, if you have a single image file, you can use it in multiple slides or scenes without having to upload the same file multiple times.

Adding media

The Library allows you to add various types of media files, including:

  • File: Representing uploaded files from users
  • String: Representing direct URLs to resources (either local or remote)
  • Uint8Array: Representing the buffer data of a resource

Here is how to add the media to the Library

const mediaData = await engine.getLibrary().addMedia(myFile);

In this example, we're uploading a file using the addMedia() method. The resulting mediaData object contains information about the added media.

Deleting media

When you delete a media file from the gallery, all associated clips will also be removed. This ensures that your media library stays organized and up-to-date.

To delete a media file from the gallery, use the deleteMedia() method and pass in the media data ID:

await engine.getLibrary().deleteMedia(mediaData.id);