Editor Integration

    Editor Integration


    Article summary

    Select Library

    app/build.gradleChoose from Live, integrated, or partitioned libraries to add them.

    Integrated library

    dependencies {
        def shoplive_sdk_version = "1.6.2"
        
        // Shoplive combined packaging
        implementation "cloud.shoplive:shoplive-sdk-all:$shoplive_sdk_version" // live + short-form + editor
    }

    Partitioned Library

    dependencies {
        def shoplive_sdk_version = "1.6.2"
        def your_exoplayer_version = "2.19.1"
        def your_media3_version = "1.4.1"
        def shoplive_exoplayer_version = your_exoplayer_version + "." + "8"
        def shoplive_media3_version = your_media3_version + "." + "8"
        
        // Shoplive split packaging
        implementation "cloud.shoplive:shoplive-common:$shoplive_sdk_version" // must required
        implementation "cloud.shoplive:shoplive-exoplayer:$shoplive_exoplayer_version" // must required
        // When using media3. Exoplayer will be deprecated soon.
        // https://developer.android.com/guide/topics/media/media3/getting-started/migration-guide
        // implementation "cloud.shoplive:shoplive-media3:$shoplive_media3_version" 
        implementation "cloud.shoplive:shoplive-network:$shoplive_sdk_version" // must required
    
        implementation "cloud.shoplive:shoplive-filter:$shoplive_sdk_version" // for short-form editor
        implementation "cloud.shoplive:shoplive-video-editor:$shoplive_sdk_version" // for short-form editor  
    
        implementation "cloud.shoplive:shoplive-sdk-core:$shoplive_sdk_version" // for live player
      
        implementation "cloud.shoplive:shoplive-short-form:$shoplive_sdk_version" // for short-form player
    }
    


    Add Proguard Rule

    If you do an R8 Build, you may run into obfuscation issues. Please add the following:

    -keep public class cloud.shoplive.** { *; }
    -dontwarn cloud.shoplive.**
    -keep class org.json.** { *; }
    -keep class com.google.gson.** { *; }


    Applying an AccessKey

    ShopLiveCommon.setAccessKey("your accessKey")

    Access Key

    Access key and secret key can be provided to you from a ShopLive representative.


    Add a largeHeap

    Low-end devices may encounter memory-related problems. AndroidManifest.xml Please add the following:

    <application
        android:largeHeap="true">


    JNI Conflict

    2 files found with path 'lib/arm64-v8a/libc++_shared.so' from inputs

    If there is a conflict, please add the following to your build.gradle:

    android {
        packagingOptions {
            pickFirst("lib/x86/libc++_shared.so")
            pickFirst("lib/x86_64/libc++_shared.so")
            pickFirst("lib/armeabi-v7a/libc++_shared.so")
            pickFirst("lib/arm64-v8a/libc++_shared.so")
        }
    }


    ShopLiveVideoEditor

    DATA SETTINGS

    You can set the properties of the Video editor.

    fun setData(data: ShopLiveVideoEditorData): ShopLiveVideoEditor

    ShopLiveVideoEditorData

    Property name

    Type

    Description

    maxVideoDuration

    Long

    Maximum Video Duration milliseconds (Default: 600000)

    minVideoDuration

    Long

    Minimum Video Duration milliseconds (Default: 1000)

    isCreatedShortform

    Boolean

    Ability to create a short-form directly (Default: true)

    outputVideoQuality

    ShopLiveVideoEditorVideoQuality

    Ability to select the quality of the output video (Default: NORMAL)

    outputResolution

    ShopLiveVideoEditorResolution

    Ability to select the resolution of the output video (Default: RESOLUTION_720)

    aspectRatio

    ShopLiveShortformEditorAspectRatio

    Ability to select the aspect ratio of the Crop function

    visibleActionButton

    ShopLiveShortformEditorVisibleActionButton

    Ability to choose the features of the video editor

    ShopLiveShortformEditorAspectRatio

    Property name

    Type

    Description

    width

    Int

    Crop width ratio (Default: 9)

    height

    Int

    Crop height ratio (Default: 16)

    isFixed

    Boolean

    Ability to maintain crop aspect ratio (Default: false)

    ShopLiveShortformEditorVisibleActionButton

    Property name

    Type

    Description

    isUsedFilterButton

    Boolean

    Ability to use Video's filters (Default: true)

    isUsedVolumeButton

    Boolean

    Available function to adjust the volume of the video (Default: true)

    isUsedPlaybackSpeedButton

    Boolean

    Ability to use the button to adjust the speed of the video (Default: true)

    isUsedCropButton

    Boolean

    Ability to use the button to resize the video (Default: true)

    Handler Settings

    Youcan set the properties of the V ideo editor.

    fun setHandler(handler: ShopLiveVideoEditorHandler): ShopLiveVideoEditor
    class ShopLiveVideoEditorHandler {
        open fun onSuccess(videoEditorActivity: ComponentActivity, result: ShopLiveEditorResultData) {
            // Do something
        }
        open fun onEvent(
            context: Context,
            command: String,
            payload: Map<String, Any?>
        ) {
            // Do something
        }
        open fun onError(error: ShopLiveCommonError) {
            // Do something
        }
        open fun onCancel() {
            // Do something
        }
    }

    ShopLiveEditorResultData

    Property name

    Type

    Description

    shortsId

    String?

    The value of the generated shortsId (this can be checked when the property isCreatedShortform in data is true)

    localVideoUri

    Uri

    Generated Local Video uri

    localCoverImageUri

    Uri

    Generated Local Cover uri

    remoteOriginVideoUrl

    String?

    Remote source Video url generated (can be checked when the data property isCreatedShortform is true)

    remoteCoverImageUrl

    String?

    Generated Remote Cover url, first frame (can be checked when the property isCreatedShortform in data is true)

    width

    Int

    width of the generated video

    height

    Int

    Height of the generated video

    duration

    Long

    Duration of the generated video

    Launch the Video editor

    Launch the Video editor.

    fun start(data: ShopLiveEditorBaseData)

    ShopLiveEditorLocalData

    This is used when using Media from the gallery.

    data class ShopLiveEditorLocalData(
        override val uri: Uri?,
    ) : ShopLiveEditorBaseData(uri)

    ShopLiveEditorCameraData

    This is used when using the camera.

    data class ShopLiveEditorCameraData(
        override val uri: Uri?,
    ) : ShopLiveEditorBaseData(uri)

    example

    ShopLiveVideoEditor(activity)
        .setData(ShopLiveVideoEditorData())
        .setHandler(object : ShopLiveVideoEditorHandler() {
            override fun onSuccess(
                videoEditorActivity: ComponentActivity,
                result: ShopLiveEditorResultData
            ) {
                super.onSuccess(videoEditorActivity, result)
            }
            override fun onError(error: ShopLiveCommonError) {
                super.onError(error)
            }
            override fun onCancel() {
                super.onCancel()
            }
        }).start(ShopLiveEditorLocalData(it))


    ShopLiveCoverPicker

    DATA SETTINGS

    You can set the properties of the Cover picker.

    fun setData(data: ShopLiveCoverPickerData): ShopLiveCoverPicker

    ShopLiveCoverPickerData

    Property name

    Type

    Description

    shortsId

    String?

    Ability to update the cover corresponding to the shortsId

    aspectRatio

    ShopLiveShortformEditorAspectRatio

    Ability to select the aspect ratio of the Crop function

    visibleActionButton

    ShopLiveCoverPickerVisibleActionButton

    Ability to choose the function of the cover picker

    ShopLiveShortformEditorAspectRatio

    Property name

    Type

    Description

    width

    Int

    Crop width ratio (Default: 9)

    height

    Int

    Crop height ratio (Default: 16)

    isFixed

    Boolean

    Ability to maintain crop aspect ratio (Default: false)

    ShopLiveShortformEditorVisibleActionButton

    Property name

    Type

    Description

    isUsedCropButton

    Boolean

    Ability to use the button to resize the video (Default: true)