1 단계 설치하기

❗️

ShopLiveHandler 를 반드시 등록하세요.

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


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

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

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

android {
   defaultConfig {
       ...
       multiDexEnabled true
       ...
   }
}

dependencies {
    // shoplive player sdk only
    implementation 'cloud.shoplive:shoplive-sdk:1.3.2'

    /*
    // already using exoplayer
    implementation "com.google.android.exoplayer:exoplayer-core:2.18.1"
    implementation "com.google.android.exoplayer:exoplayer-hls:2.18.1"
    implementation "com.google.android.exoplayer:exoplayer-ui:2.18.1"
    implementation "com.google.android.exoplayer:extension-okhttp:2.18.1"

    implementation 'cloud.shoplive:shoplive-sdk-core:1.3.2'
    implementation 'cloud.shoplive:shoplive-exoplayer:2.18.1.1'
    */
}

AndroidManifest.xml에 아래 Application을 등록하세요.

<application
        android:name=".YourApplication"
       .
       .>
</application>

YourApplication.kt에 아래 코드를 추가하세요.

class YourApplication: Application() {

    override fun onCreate() {
        super.onCreate()
    }
}

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) {
    }
})