1 단계 설치하기

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.1'

    /*
    // 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.1'
    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) {
    }
})