Shopliveプレビュー再生のカスタマイズ
- 印刷する
Shopliveプレビュー再生のカスタマイズ
- 印刷する
記事の要約
この要約は役に立ちましたか?
ご意見ありがとうございます
デフォルトの「アプリ内プレビュー」を使用する
プレビューは、Shoplive SDKが提供する ShopLivePreview を使用して自分で実装することができます。
activity.xml
// 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" />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)プレビューを音声付きで再生する
プレビューはデフォルトでミュートです(isMuted = true)。再生開始から音声を出すにはミュートを解除してください。
ポップアッププレビュー — ShopLive.showPreviewPopup
ShopLive.showPreviewPopup(
activity,
ShopLivePreviewData(campaignKey).apply {
// デフォルトは true(ミュート)です。最初から音声を出すには false を設定してください。
isMuted = false
// ユーザーが音量キーでミュートを操作できるようにするには併せて設定してください。デフォルトは false。
isEnabledVolumeKey = true
}
)インラインプレビュー — レイアウトに ShopLivePreview を配置した場合
preview.setMuted(false)
preview.setEnabledVolumeKey(true) // 任意ミュートを解除しても、放送映像自体に音声がない場合は音が出ません。音が聞こえない場合は、まずその放送に音声トラックがあるかご確認ください。
Swipe操作でシャットダウンできるアプリ内プレビューを使用する
ShopLiveSwipePreview を使用すると、スワイプしてプレビューを終了できます。使用方法はShopLivePreviewと同様です。
activity.xml
<cloud.shoplive.sdk.ShopLiveSwipePreview
android:id="@+id/swipePreview"
android:layout_width="something dimens"
android:layout_height="something dimens" />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)