class AudioOverlayConfiguration(private val activity: AppCompatActivity) : Example(activity) {
override fun invoke() {
val settingsList = VideoEditorSettingsList(false)
.configure<LoadSettings> {
it.source = activity.resourceUri(R.raw.skater)
}
settingsList.config.addAsset(
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)),
)
settingsList.configure<UiConfigAudio> {
it.setAudioTrackLists(
AudioTrackCategoryItem(
"audio_cat_elsewhere", "Elsewhere", AudioTrackItem("id_elsewhere"), AudioTrackItem("id_trapped")
),
AudioTrackCategoryItem(
"audio_cat_others", "Others", AudioTrackItem("id_dance"), AudioTrackItem("id_far_from_home")
),
CustomAudioTrackCategoryItem(
id = "audio_custom_category",
fragmentClass = ExampleAudioFragment::class.java,
name = "Custom"
)
)
SpaceItem.fillListSpacedByGroups(
list = it.quickOptionList, groups = listOf(
listOf(),
listOf(
ToggleOption(
AudioOverlayOptionsToolPanel.OPTION_PLAY_PAUSE,
"Play/Pause",
ImageSource.create(
ly.img.android.pesdk.ui.R.drawable.imgly_icon_play_pause_option
)
)
),
listOf()
)
)
}
VideoEditorBuilder(activity)
.setSettingsList(settingsList)
.startActivityForResult(activity, EDITOR_REQUEST_CODE)
settingsList.release()
}
override fun onActivityResult(requestCode: Int, resultCode: Int, intent: Intent?) {
intent ?: return
if (requestCode == EDITOR_REQUEST_CODE) {
val result = EditorSDKResult(intent)
when (result.resultStatus) {
EditorSDKResult.Status.CANCELED -> showMessage("Editor cancelled")
EditorSDKResult.Status.EXPORT_DONE -> showMessage("Result saved at ${result.resultUri}")
else -> {
}
}
}
}
}