1단계 설치하기

❗️

ShopLiveHandler 를 반드시 등록하세요.

ShopLive.setHandler 인터페이스를 통해서 ShopLiveHandler를 등록하지 않으면 방송 진입 후에 플레이어가 바로 종료됩니다. 아래 Handler 등록하기 가이드를 참고하세요.


project/build.gradle에 아래 코드를 추가하세요.

allprojects {
    repositories
        ...
        maven { url 'https://shoplivesdk.jfrog.io/artifactory/shoplive-sdk/' }
        ...
    }
}

app/build.gradle에 Live 라이브러리, 통합된 라이브러리, 분할된 라이브러리 중 선택해서 추가하세요.

  1. Live 라이브러리
dependencies {
    def shoplive_sdk_version = "1.5.0"
  
    // Shoplive live player
    implementation "cloud.shoplive:shoplive-sdk:$shoplive_sdk_version"
}

  1. 통합된 라이브러리
dependencies {
    def shoplive_sdk_version = "1.5.0"
    
    // Shoplive combined packaging
    implementation "cloud.shoplive:shoplive-sdk-all:$shoplive_sdk_version" // live + short-form
}

  1. 분할된 라이브러리
dependencies {
    def shoplive_sdk_version = "1.5.0"
    def your_exoplayer_version = "2.19.1"
    def your_media3_version = "1.1.1"
    def shoplive_exoplayer_version = your_exoplayer_version + "." + "7"
    def shoplive_media3_version = your_media3_version + "." + "7"
    
    // 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-sdk-core:$shoplive_sdk_version" // for live player
  
    implementation "cloud.shoplive:shoplive-short-form:$shoplive_sdk_version" // for short-form player
}

Handler 등록하기

Shoplive Android SDK로부터 여러 이벤트를 수신할 Handler를 등록하세요.

ShopLive.setHandler(object : ShopLiveHandler {
    override fun handleNavigation(context: Context, url: String) {
    }

    override fun handleDownloadCoupon(
        context: Context,
        couponId: String,
        callback: ShopLiveHandlerCallback) {

    }

    override fun onChangeCampaignStatus(
        context: Context, 
        campaignStatus: String) {
    }

    override fun onCampaignInfo(campaignInfo: JSONObject) {
    }

    override fun onError(context: Context, code: String, message: String) {
    }

    override fun handleShare(context: Context, shareUrl: String) {
    }

    override fun handleCustomAction(
        context: Context, 
        id: String, 
        type: String, 
        payload: String,
        callback: ShopLiveHandlerCallback) {
    }

    override fun onChangedPlayerStatus(
        isPipMode: Boolean, 
        state: String) {
        super.onChangedPlayerStatus(isPipMode, state)
    }

    override fun onSetUserName(jsonObject: JSONObject) {
        super.onSetUserName(jsonObject)
    }

    override fun onReceivedCommand(
        context: Context, 
        command: String, 
        data: JSONObject) {
    }
})