Skip to main content

From Remote URL

VideoEditor SDK supports loading audio files from a remote URL, this can be a resource hosted by a hosting provider or your own servers.

For each audio clip, we construct a remote URL from the clip identifier and create a download task. Upon successful download, we save it to a temporary location after checking if a file already exists at that location and removing it if necessary.

In order to keep the UI responsive and prevent race conditions while the audio files are downloading, we dispatch to the main queue. Here, we keep track of the finished download task and the locations of the downloaded clip by writing to a downloadLocations dictionary.

Now once all clips have finished downloading, we can retrieve their local URLs and identifiers from the downloadLocations dictionary and pass them to the AudioClip constructor. AudioClip objects, additionally, hold metadata such as a thumbnailURL and the duration of the clip.

We then need to add the audio clips to an AudioClipCategory object which holds the metadata of the category such as a preview image and a title.

Finally, we can configure the assetCatalog by assigning an array of the audio clip categories we want to include to the audioClips property.