API: Option

    API: Option


    Article summary

    ShopLive.setUser

    Setting user information for Shoplive.

    fun setUser(user: ShopLiveUser)

    Sample code

    val user = ShopLiveCommonUser().apply {
    	userId = "testId"
    	userName = "kate"
    	age = 20
    	gender = ShopLiveCommonUserGender.NEUTRAL
    	userScore = 100
    }
    
    ShopLive.setUser(user)

    enum ShopLiveUserGender

    Value

    Explanation

    Male

    male

    Female

    female

    Neutral

    No gender specified


    ShopLive.setAuthToken

    This is the security authentication token (JWT) string of the authenticated user using Shoplive. For user authentication, enter the authenticated user's security authentication token (JWT) string.

    fun setAuthToken(authToken: String)

    Sample code

    val generatedJWT = "eyJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2MTA1NzA1dfadsfasfadsfasdfwO"
    
    ShopLive.setAuthToken(generatedJWT)


    ShopLive.getAuthToken

    Returns the JWT token string for user authentication.

    fun getAuthToken(): String

    Sample code

    ShopLive.getAuthToken()


    ShopLive.setPIPRatio

    This is the default screen scale when starting PIP screen mode. When you start PIP screen mode after playing for the first time, PIP screen mode starts with the specified screen scale.

    fun setPIPRatio(ratio: ShopLivePIPRatio)

    enum ShopLivePIPRatio

    Value

    Description

    RATIO_1X1

    1 × 1

    RATIO_1X2

    1 x 2

    RATIO_2X3

    2 x 3

    RATIO_3X4

    3 x 4

    RATIO_9X16

    9 x 16


    ShopLive.setKeepPlayVideoOnHeadphoneUnplugged

    The video stops when the earphones (or headset) are disconnected. You can set the video to play continuously or leave it muted upon your needs

    • To change to silent mode when Bluetooth earphones (or headset) are disconnected, you need to declare BLUETOOTH_CONNECT in AndroidManifest.xml and then grant runtime permission before entering the broadcast, if you want to set it with setKeepPlayVideoOnHeadphoneUnplugged(true, true).

    AndroidManifest.xml

    <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
    fun setKeepPlayVideoOnHeadphoneUnplugged(isKeepPlayVideoOnHeadphoneUnplugged: Boolean)
    fun setKeepPlayVideoOnHeadphoneUnplugged(isKeepPlayVideoOnHeadphoneUnplugged: Boolean, isMute: Boolean)

    Parameter name

    Type

    Description

    isKeepPlayVideoOnHeadphoneUnplugged

    Boolean

    • true: Continue playing video : Pause video

    • false

    isMute

    Boolean

    • true: Process system volume mute : Maintain system volume playback

    • false


    ShopLive.setAutoResumeVideoOnCallEnded

    When you return to the video after ending the call, the video will continue to play. However, you can set the video to pause if necessary. The required permission is READ_PHONE_STATE.

    fun setAutoResumeVideoOnCallEnded(isAutoResumeVideoOnCallEnded: Boolean)

    Parameter name

    Type

    Description

    isAutoResumeVideoOnCallEnded

    Boolean

    • true: Continue playing video

    • false: Pause video


    ShopLive.setShareScheme

    When selecting the Share, set the URL or scheme to be passed.

    fun setShareScheme(shareUrl: String)

    Parameter name

    Type

    Description

    shareUrl

    String

    The url orscheme to share.

    Sample code

    val scheme = "shoplive://live" // or "https://shoplive.cloud/live"
    
    ShopLive.setShareScheme(scheme)


    ShopLive.setLoadingProgressColor

    Set the video loading progress bar color.

    fun setLoadingProgressColor(@ColorInt colorInt: Int)

    Parameter name

    Type

    Description

    colorInt

    ColorInt

    The color to set for progress bar

    Sample code

    ShopLive.setLoadingProgressColor(Color.WHITE)


    ShopLive.setLoadingAnimation

    Set the video loading progress bar as an image animation.

    fun setLoadingAnimation(animationDrawable: Int)

    Parameter name

    Type

    Description

    animationDrawablecolorInt

    ColorInt

    The image array resources

    Sample code

    ShopLive.setLoadingAnimation(R.drawable.progress_animation)
    
    ShopLive.setLoadingAnimation(0)


    ShopLive.setChatViewTypeface

    Set the chat font and chat send button font.

    • To apply the same font to both the chat and the chat send button, call the setChatViewTypeface(typeface) function.

    fun setChatViewTypeface(typeface: Typeface)

    Parameter name

    Type

    Description

    typeface

    Typeface

    Common font for chat font and chat send button font

    Sample code

    val nanumGothic = resources.getFont(R.font.nanumgothic)
    val nanumGothicBold = resources.getFont(R.font.nanumgothicbold)
    
    ShopLive.setChatViewTypeface(nanumGothic)


    ShopLive.setEnterPipModeOnBackPressed

    While watching a video, selecting (tapping) the back button to exit the screen will end the video. However, this option can be used to switch to Picture-in-Picture (PIP) mode and continue watching the video.

    fun setEnterPipModeOnBackPressed(isEnterPipModeOnBackPressed: Boolean)

    Parameter name

    Type

    Description

    isEnterPipModeOnBackPressed

    Boolean

    • true: Switch to PIP screen mode

    • false: End video

    Sample code

    ShopLive.setEnterPipModeOnBackPressed(true)


    ShopLive.close

    Close the player.

    fun close()


    ShopLive.setAutoCloseWhenAppDestroyed

    You can set it so that the player does not close even if the root activity is terminated.

    The reason for using this option is to prevent the broadcast from ending when the root activity is relaunched using the Intent.FLAG_ACTIVITY_NEW_TASK option. It allows for the ShopLive.close function to be called directly to properly terminate the broadcast when the app is appropriately closing.

    • Default: Automatic termination

    • If not set, the player will close when the app is closed.

    fun setAutoCloseWhenAppDestroyed(isAutoClose: Boolean)

    Parameter name

    Type

    Description

    isAutoClose

    Boolean

    • true: Broadcast ends when app closes (default).

    • false: Broadcast does not end when app closes.

    Sample code

    ShopLive.setAutoCloseWhenAppDestroyed(false)


    ShopLive.startPictureInPicture

    Switch from full screen mode to PIP screen mode.

    fun startPictureInPicture()

    Sample code

    ShopLive.startPictureInPicture()


    ShopLive.stopPictureInPicture

    Switch PIP screen mode to full screen mode.

    fun stopPictureInPicture()

    Sample code

    ShopLive.stopPictureInPicture()


    ShopLive.getStatus

    Retrieve the status of the Shoplive player.

    fun getStatus(): Status

    enum Status

    Value

    Description

    None

    no status

    PIP

    picture-in-picture mode

    Full

    full screen mode

    Sample code

    ShopLive.getStatus()


    ShopLive.isShowingPreviewPopup

    This is the information provided when successfully entering the Shoplive Preview.

    fun isShowingPreviewPopup(): Boolean

    Sample code

    ShopLive.isShowingPreviewPopup()


    ShopLive.isSuccessCampaignJoin

    This is information provided when entry into the broadcast is successful.

    fun isSuccessCampaignJoin(): Boolean

    Sample code

    ShopLive.isSuccessCampaignJoin()


    ShopLive.sendCommandMessage

    Delivers commands and payload to the server. You can pass commands and payloads in predefined formats. (Alternatively, you can define the command and payload in consultation with Shoplive.)

    fun sendCommandMessage(command: String, payload: Map<String, Any?>)

    Parameter name

    Type

    Description

    command

    String

    The pre-definedcommand

    payload

    Map<String,Any?>

    The pre-definedpayload

    Sample code

    val command = "COMMAND_NAME"
    val payload = mapOf<String, Any?>(Pair("Int_Data", 1), Pair("String_Data", "Sample_String"))
    
    ShopLive.sendCommandMessage(command, payload)


    ShopLive.setMuteWhenPlayStart

    Set the sound to turn on or mute when you start Shoplive Player. (Default: Starts Shoplive Player with sound turned on.)

    fun setMuteWhenPlayStart(isMute: Boolean)

    Parameter name

    Type

    Description

    isMute

    Boolean

    Whether to mute:

    • true : Start with mute

    • false : Start with sound on

    Sample code

    ShopLive.setMuteWhenPlayStart(true)
    
    ShopLive.setMuteWhenPlayStart(false)


    ShopLive.setAppVersion

    Set the app version. Even if you don't call the API, the app version is read by default and passed to the server. Please contact your Shoplive representative to use this feature.

    fun setAppVersion(appVersion: String)

    Parameter name

    Type

    Description

    appVersion

    String

    The version of an app.

    Sample code

    val appVersion: String = “1.0.0”
    ShopLive.setAppVersion(appVersion)


    ShopLive.setVisibleStatusBar

    You can hide the StatusBar on the screen.

    fun setVisibleStatusBar(isVisible: Boolean)

    Parameter name

    Type

    Description

    isVisible

    Boolean

    Set whether to hide the status bar

    • true: Show status bar (default value)

    • false: Hide status bar

    Sample code

    ShopLive.setVisibleStatusBar(true)


    ShopLive.setSystemBarColor

    You can change the color of the SystemBar on your screen.

    fun setSystemBarColor(data: ShopLivePlayerSystemBarColorData)

    Parameter name

    Type

    Description

    data

    ShopLivePlayerSystemBarColorData

    SystemBar color data

    ShopLivePlayerSystemBarColorData

    Property name

    Type

    Description

    statusBarColor

    ColorInt

    You can change the StatusBar color.

    • Default: ShopLivePlayerSystemBarColorData.DEFAULT_COLOR

    navigationBarColor

    ColorInt

    You can change the SystemBar color.

    • Default: ShopLivePlayerSystemBarColorData.DEFAULT_COLOR

    Sample code

    ShopLive.setSystemBarColor(ShopLivePlayerSystemBarColorData().apply {
        statusBarColor = Color.TRANSPARENT
    })


    ShopLive.setSoundFocusHandling

    If a phone call comes in while playing a video or the sound is suppressed due to the use of another app's player, you can receive the event and handle it directly.

    fun setSoundFocusHandling(listener: OnAudioFocusListener?)

    Parameter name

    Type

    Description

    listener

    OnAudioFocusListener?

    AudioFocusListener

    Sample code

    ShopLive.setSoundFocusHandling(object : OnAudioFocusListener {
        override fun onGain() {
            ShopLive.unmute()
        }
    
        override fun onLoss() {
            ShopLive.mute()
        }
    })


    ShopLive.showDialogFragment

    Used to display the user's DialogFragment on the Shoplive Player screen.

    fun showDialogFragment(dialogFragment: DialogFragment)

    Parameter name

    Type

    Description

    dialogFragment

    DialogFragment

    User's DialogFragment

    Sample code

    override fun handleNavigation(context: Context, url: String) {
        val nexcActionType = "{your_action_type}"
        when(nexcActionType) {
            ShopLive.ActionType.KEEP -> {
                ShopLive.showDialogFragment(WebViewDialogFragment(url))
            }
        }
    }


    ShopLive.closeDialogFragment

    To close the dialog displayed using the ShopLive.showDialogFragment(fragment).

    fun closeDialogFragment()

    Sample code

    ShopLive.closeDialogFragment()


    ShopLive.setPlayerScreenCaptureEnabled

    You can prevent screenshots of the broadcast screen.

    fun setPlayerScreenCaptureEnabled(isEnabled: Boolean)

    Parameter name

    Type

    Description

    isEnabled

    Boolean

    • true: Activate screen capture function

    • false: Disable screen capture function

    Sample code

    ShopLive.setPlayerScreenCaptureEnabled(false)
    
    ShopLive.setPlayerScreenCaptureEnabled(true)


    ShopLive.setMixWithOthers

    When external audio is played, you can config the livestream audio.

    fun setMixWithOthers(isMixAudio: Boolean)

    Parameter name

    Type

    Description

    isMixAudio

    Boolean

    • true: Watch broadcast with external audio (default)

    • false: Player pauses when external audio is played

    Sample code

    ShopLive.setMixWithOthers(false)
    
    ShopLive.setMixWithOthers(true)


    ShopLive.setUtmSource

    You can track UTM Source. Data can be checked at Data Insights.

    fun setUtmSource(utmSource: String)

    Parameter name

    Type

    Description

    utmSource

    String

    It conveys where the inflow occurred.

    Sample code

    ShopLive.setUtmSource(“{utm_source}”)


    ShopLive.setUtmMedium

    You can track UTM Medium. Data can be checked at Data Insights.

    fun setUtmMedium(utmMedium: String)

    Parameter name

    Type

    Description

    utmMedium

    String

    It conveys how the inflow occurred. Google recommends setting the medium parameter to refer to the marketing method that led to the inflow. (ex. cpc, banner, email, blog, social etc.)

    Sample code

    ShopLive.setUtmMedium(“{utm_medium}”)


    ShopLive.setUtmCampaign

    You can track UTM Campaigns. Data can be checked at Data Insights.

    fun setUtmCampaign(utmCampaign: String)

    Parameter name

    Type

    Description

    utmCampaign

    String

    It tells you which advertising campaign the inflow occurred. It can be divided into Campaign Name, Campaign Term, and Campaign Content.

    Sample code

    ShopLive.setUtmCampaign(“{utm_campaign}”)


    ShopLive.setUtmContent

    You can track UTM Content. Data can be checked at Data Insights.

    fun setUtmContent(utmContent: String)

    Parameter name

    Type

    Description

    utmContent

    String

    It conveys what kind of content the inflow was caused by a posting/advertisement. It is mainly used as a subdivision of campaign parameters.

    Sample code

    ShopLive.setUtmContent(“{utm_content}”)


    ShopLive.addParameter

    You can add custom data before launching the player.

    fun addParameter(key: String, value: String)

    Parameter name

    Type

    Description

    key

    String

    Custom parameter key to apply additionally

    value

    String

    Additional custom parameter value to apply

    Sample code

    ShopLive.addParameter(“{key}”, “{value}”)


    ShopLive.removeParameter

    Before running the player, delete the custom data added with the addParameter.

    fun removeParameter(key: String)

    Parameter name

    Type

    Description

    key

    String

    Parameter key to delete

    Sample code

    ShopLive.removeParameter(“{key}”)


    ShopLive.setNextActionOnHandleNavigation

    Set the next action of Shoplive Player when the user selects a link such as a product, notice, or banner.

    fun setNextActionOnHandleNavigation(type: ActionType)

    enum ActionType

    Value

    Description

    PIP

    switch to PIP

    KEEP

    keep current status

    CLOSE

    close

    Sample code

    ShopLive.setNextActionOnHandleNavigation(ActionType.PIP)


    ShopLive.setEndpoint

    This is used when you need to utilize the Shoplive service from a specific landing page or URL, rather than the Web Landing page of the Shoplive Player. For instance, in cases where the Shoplive Landing page cannot be used due to security reasons, you can create a landing page on a specific domain.

    The Web Landing page of the Shoplive Player can be implemented after consultation with Shoplive.

    fun setEndpoint(url: String)

    Parameter name

    Type

    Description

    url

    String

    Shoplive Player's Web Landing URL

    Sample code

    ShopLive.setEndpoint("https://www.your_landingpage.com/")


    ShopLive.setResizeMode

    Set the aspect ratio of a video. (Default: ShopLiveResizeMode.CENTER_CROP)

    fun setResizeMode(resizeMode: ShopLiveResizeMode)