Shopliveプレビュー再生のカスタマイズ

    Shopliveプレビュー再生のカスタマイズ


    記事の要約

    デフォルトの「アプリ内プレビュー」を使用する

    プレビューは、Shoplive SDKが提供する  ShopLivePreview を使用して自分で実装することができます。

    // If only one of width or height is written, it is flexible.
    <cloud.shoplive.sdk.ShopLivePreview
        android:id="@+id/preview"
        android:layout_width="something dimens"
        android:layout_height="something dimens" />

    PlainText

    preview.start(“{accessKey}”, “{campaignKey}”)
    preview.setOnClickListener {
        // Preview transition animation
        ShopLive.setPreviewTransitionAnimation(requireActivity(), binding.preview)
        ShopLive.play(requireActivity(), campaignKey)
        preview.release()
    }
    
    // For lifecycle observing preview
    preview.setLifecycleObserver(this.viewLifecycleOwner)

    PlainText


    Swipe操作でシャットダウンできるアプリ内プレビューを使用する

    ShopLiveSwipePreview を使用すると、スワイプしてプレビューを終了できます。使用方法はShopLivePreviewと同様です。

    <cloud.shoplive.sdk.ShopLiveSwipePreview
        android:id="@+id/swipePreview"
        android:layout_width="something dimens"
        android:layout_height="something dimens" />

    PlainText

    swipePreview.start(“{accessKey}”, “{campaignKey}”)
    swipePreview.setOnPreviewClickListener {
        // Preview transition animation
        ShopLive.setPreviewTransitionAnimation(requireActivity(), binding.preview)
        ShopLive.play(requireActivity(), campaignKey)
        swipePreview.release()
    }
    
    // For lifecycle observing preview
    swipePreview.setLifecycleObserver(this.viewLifecycleOwner)

    PlainText