Skip to main content
VESDK/Android/Guides/Stickers/Add Stickers
Language:

From Resources

VideoEditor SDK supports adding custom stickers from the resources. In this example, we load both a custom sticker and an existing sticker from the assets:sticker-emoticons module.

Custom sticker asset#

Here, we create a custom sticker using ImageStickerAsset. It takes in a unique identifier (used for serialization/deserialization purposes), and the sticker's resource drawable.

Add sticker to AssetConfig#

To use the sticker, it must first be available in the SDK's backend. This is done by adding the sticker to the AssetConfig.

Create a custom sticker category#

We then add the stickers to a StickerCategoryItem and provide it with an id, name, and thumbnail ImageSource.

Configure UiConfigSticker#

Here, we configure UiConfigSticker and add the custom sticker category as the first item in the list.

File:
class VideoAddStickersFromResources(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)
}
// Create a custom sticker
val customSticker = ImageStickerAsset(
"custom_sticker",
R.drawable.custom_sticker_igor
)
val existingSticker = ImageStickerAsset(
"imgly_sticker_emoticons_grin",
ly.img.android.pesdk.assets.sticker.emoticons.R.drawable.imgly_sticker_emoticons_grin
)
// Add custom sticker to AssetConfig
settingsList.config.addAsset(customSticker)
// Create custom sticker category
val customStickerCategory = StickerCategoryItem(
"custom_sticker_category",
"Custom",
ImageSource.create(R.drawable.custom_sticker_igor_thumb),
ImageStickerItem("custom_sticker", "Igor", ImageSource.create(R.drawable.custom_sticker_igor_thumb)),
ImageStickerItem(
"imgly_sticker_emoticons_grin",
"Grin",
ImageSource.create(ly.img.android.pesdk.assets.sticker.emoticons.R.drawable.imgly_sticker_emoticons_grin)
)
)
settingsList.configure<UiConfigSticker> {
// Add custom sticker category to the UI
it.stickerLists.add(0, customStickerCategory)
}
// Start the video editor using VideoEditorBuilder
// The result will be obtained in onActivityResult() corresponding to EDITOR_REQUEST_CODE
VideoEditorBuilder(activity)
.setSettingsList(settingsList)
.startActivityForResult(activity, EDITOR_REQUEST_CODE)
// Release the SettingsList once done
settingsList.release()
}
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 -> {
}
}
}
}
}