Skip to main content

From Resources

VideoEditor SDK supports loading audio files from the resources.

Add audio assets to AssetConfig#

To use the audio clips, they must first be available in the SDK's backend. This is done by adding the audio assets to the AssetConfig. The AudioTrackAsset takes in a unique identifier, an AudioSource, and optionally the title, artist, and duration in seconds. Note that the AudioSource class is not optimized to handle remote resources, see next section on how to handle loading audio clips from remote resource.

Create categories#

We then add the audio clips to an AudioTrackCategoryItem object that holds the metadata of the category such as a unique identifier, title, and optionally a preview image.

The AudioTrackItem uses the same identifier as the one specified when creating the corresponding AudioTrackAsset. It also optionally takes an ImageSource that is used to display its thumbnail.

Configure UiConfigAudio#

Here, we configure UiConfigAudio and set the audio track lists.

class AddAudioOverlaysFromResources(private val activity: AppCompatActivity) : Example(activity) {
override fun invoke() {
// In this example, we do not need access to the Uri(s) after the editor is closed
// so we pass false in the constructor
val settingsList = VideoEditorSettingsList(false)
// Set the source as the Uri of the video to be loaded
.configure<LoadSettings> {
it.source = activity.resourceUri(R.raw.skater)
// Add the custom audio clips to the asset config
AudioTrackAsset("id_elsewhere", AudioSource.create(R.raw.elsewhere)),
AudioTrackAsset("id_trapped", AudioSource.create(R.raw.trapped_in_the_upside_down)),
AudioTrackAsset("id_dance", AudioSource.create(R.raw.dance_harder)),
AudioTrackAsset("id_far_from_home", AudioSource.create(R.raw.far_from_home)),
val audioTrackCategories = listOf(
"audio_cat_elsewhere", "Elsewhere", AudioTrackItem("id_elsewhere"), AudioTrackItem("id_trapped")
"audio_cat_others", "Others", AudioTrackItem("id_dance"), AudioTrackItem("id_far_from_home")
settingsList.configure<UiConfigAudio> {
// Start the video editor using VideoEditorBuilder
// The result will be obtained in onActivityResult() corresponding to EDITOR_REQUEST_CODE
.startActivityForResult(activity, EDITOR_REQUEST_CODE)
// Release the SettingsList once done
override fun onActivityResult(requestCode: Int, resultCode: Int, intent: Intent?) {
intent ?: return
if (requestCode == EDITOR_REQUEST_CODE) {
// Wrap the intent into an EditorSDKResult
val result = EditorSDKResult(intent)
when (result.resultStatus) {
EditorSDKResult.Status.CANCELED -> showMessage("Editor cancelled")
EditorSDKResult.Status.EXPORT_DONE -> showMessage("Result saved at ${result.resultUri}")
else -> {