API: Play

    API: Play


    Article summary

    ShopLive.setAccessKey

    You must set AccessKey to use Shoplive Android SDK.

    fun setAccessKey(accessKey: String)

    Parameter name

    Type

    Description

    accesskey

    String

    ShopLive AccessKey

    Sample code

    ShopLive.setAccessKey("{AccessKey}")


    ShopLive.play

    Starting video play with CampaignKey.

    fun play(context: Context, data: ShopLivePlayerData)
    fun intentPlay(context: Context, data: ShopLivePlayerData): Intent

    Parameter name

    Type

    Description

    context

    Context

    context

    data

    ShopLivePlayerData

    ShopLivePlayerData

    ShopLivePlayerData

    Property name

    Type

    Description

    campaignKey

    String

    Campaign key of video

    keepWindowStateOnPlayExecuted

    Boolean

    Whether to start playing while keeping the current play mode (pip, fullscreen) of the player.

    • true: Keeps the current play mode of the playing player

    • false: Will be executed in fullscreen mode (Default)

    referrer

    String?

    Referrer information

    Sample code

    ShopLive.play(this, ShopLivePlayerData(campaignKey).apply {
        keepWindowStateOnPlayExecuted = false
        referrer = "referrer"
    })


    ShopLive.showPreviewPopup

    The campaign (broadcast) key is used to play the video in mute mode in the preview view.

    fun showPreviewPopup(data: ShopLivePreviewData)

    Parameter name

    Type

    Description

    activity

    Activity

    Activity

    data

    ShopLivePreviewData

    Preview-related data

    ShopLivePreviewData

    Property name

    Type

    Description

    campaignKey

    String

    campaign key to play

    maxHeight

    Int

    max height (default 180dp)

    maxWidth

    Int

    max width (default 180dp)

    marginTop

    Int

    margin Top (default 16dp)

    marginBottom

    Int

    margin Bottom (default 16dp)

    marginLeft

    Int

    margin Left (default 16dp)

    marginRight

    Int

    margin Right (default 16dp)

    isMuted

    Boolean

    mute feature (default false)

    canTransition

    Boolean

    Whether to Use Screen Transition Animation

    canVibrated

    Boolean

    Whether to Vibrate When Moving the Preview Off the Screen

    useCloseButton

    Boolean

    Visibility of the Close Button on the Preview

    enabledSwipeOut

    Boolean

    Determines whether to allow closing the Preview by moving it off the screen

    useCustomAction

    Boolean

    Instead of directly moving to the broadcast detail screen, the event is passed to the onClickListener

    position

    ShopLivePreviewPositionConfig

    Specifies the position of the Preview:

    • TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_RIGHT

    referrer

    String?

    Referrer tracking

    onClickListener

    View.OnClickListener?

    Event handler for clicks on the Preview

    onCloseListener

    ShopLivePreview.OnCloseListener?

    Event handler for close on the Preview

    ShopLive.setPreviewTransitionAnimation

    When using the useCustomAction feature in the Preview function, you can utilize the transitionAnimation.

    fun setPreviewTransitionAnimation(activity: Activity, view: View?)

    Sample code

    ShopLive.showPreviewPopup(this, ShopLivePreviewData(campaignKey).apply {
        useCloseButton = true
        enabledSwipeOut = true
        useCustomAction = true
        onClickListener = OnClickListener { view ->
            ShopLive.setPreviewTransitionAnimation(this@MainActivity, view)
            ShopLive.play(this@MainActivity, ShopLivePlayerData(campaignKey).apply {
                referrer = viewModel.getReferrerText()
            })
        }
        onCloseListener = ShopLivePreview.OnCloseListener { view ->
            view.destroy()
        }
    })


    ShopLive.hidePreviewPopup

    Hides the popup-style preview that is currently playing.

    fun hidePreviewPopup()

    Sample code

    ShopLive.hidePreviewPopup()


    ShopLivePreview

    You can implement the preview directly through the ShopLivePreview or ShopLiveSwipePreview components.

    start

    Starting to play preview

    fun start(accessKey: String?, campaignKey: String?)

    Parameter name

    Type

    Description

    accessKey

    String?

    access key

    campaignKey

    String?

    campaign key

    pause

    Pausing preview

    fun pause()

    play

    Resuming preview

    fun play()

    release

    Releasing (terminating) preview

    fun release()

    setLifecycleObserver

    By registering a LifecycleOwner, the preview player can automatically play or pause according to the lifecycle.

    fun setLifecycleObserver(owner: LifecycleOwner)

    Parameter name

    Type

    Description

    owner

    LifecycleOwner

    LifecycleOwner

    setOnCloseListener

    You can receive events for the termination of the preview.

    fun setOnCloseListener(onCloseListener: OnCloseListener)

    setOnDimensionRatioListener

    You can obtain the aspect ratio of the preview screen.

    fun setOnDimensionRatioListener(onDimensionRatioListener: OnDimensionRatioListener)


    What's Next