- 인쇄
API: Option
- 인쇄
ShopLive.setUser
Shoplive를 사용하는 인증 사용자를 설정합니다. 사용자 인증을 하려면 사용자 정보를 입력하세요.
fun setUser(user: ShopLiveCommonUser?)Sample code
val user = ShopLiveCommonUser().apply {
userId = "testId"
userName = "kate"
age = 20
gender = ShopLiveCommonUserGender.NEUTRAL
userScore = 100
}
ShopLive.setUser(user)enum ShopLiveCommonUserGender
Value | Description |
|---|---|
MALE | 남성 |
FEMALE | 여성 |
NEUTRAL | 성별 지정 안 함 |
적용 가이드: 간편 인증 사용자 계정 연동
ShopLive.setAuthToken
Shoplive를 사용하는 인증된 사용자의 보안 인증토큰(JWT) string입니다. 사용자 인증을 위해 인증된 사용자의 보안 인증토큰(JWT) string을 입력합니다.
fun setAuthToken(authToken: String)Sample code
val generatedJWT = "eyJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2MTA1NzA1dfadsfasfadsfasdfwO"
ShopLive.setAuthToken(generatedJWT)적용 가이드: 보안 인증 사용자 계정 연동
ShopLive.getAuthToken
Shoplive를 사용하는 인증된 사용자의 보안 인증토큰(JWT) string입니다. 사용자 인증을 위해 인증된 사용자의 보안 인증토큰(JWT) string을 반환합니다.
fun getAuthToken(): StringSample code
ShopLive.getAuthToken()ShopLive.setEnabledPictureInPictureMode
Shoplive player를 벗어나는 경우 기본적으로 지정되는 pip모드를 사용하지 않는 옵션입니다.
fun setEnabledPictureInPictureMode(isEnabled: Boolean)Sample code
ShopLive.setEnabledPictureInPictureMode(true)ShopLive.setPIPRatio
PIP 화면 모드를 시작할 때 기본 화면 배율입니다. 처음 재생 후 PIP 화면 모드를 시작하면 지정된 화면 배율로 PIP 화면 모드를 시작합니다.
fun setPIPRatio(ratio: ShopLivePIPRatio)Sample code
ShopLive.setPIPRatio(ShopLivePIPRatio.RATIO_9X16)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 |
적용 가이드: PIP(Picture-in-Picture)로 전환하기
ShopLive.setKeepPlayVideoOnHeadphoneUnplugged
이어폰 (또는 헤드셋) 연결이 끊겼을 때 동영상이 멈춥니다. 하지만, 필요한 경우 동영상을 계속 재생하도록 설정할 수 있고, 음소거 상태로 처리할 수 있습니다.
블루투스 이어폰 (또는 헤드셋)이 끊겼을 때 무음으로 변경하기
setKeepPlayVideoOnHeadphoneUnplugged(true, true)로 설정하려면 AndroidManifest.xml에BLUETOOTH_CONNECT선언 후, 방송 진입 전에 먼저 런타임 권한을 허용해야 합니다.
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 |
|
isMute | Boolean |
|
Sample code
// 이어폰 (또는 헤드셋) 연결이 끊겼을 때 동영상 일시 정지로 설정
ShopLive.setKeepPlayVideoOnHeadphoneUnplugged(false)
// 이어폰 (또는 헤드셋) 연결이 끊겼을 때 동영상 계속 재생으로 설정
ShopLive.setKeepPlayVideoOnHeadphoneUnplugged(true)
// 이어폰 (또는 헤드셋) 연결이 끊겼을 때 동영상 계속 재생으로 설정하고, 음소거 처리
ShopLive.setKeepPlayVideoOnHeadphoneUnplugged(true, true)적용 가이드: 이어폰 (또는 헤드셋) 연결 끊김으로 인한 인터럽트
ShopLive.setKeepPlayVideoOnHeadphoneUnplugged
통화 종료 후 동영상으로 되돌아 왔을 때 계속 동영상이 재생됩니다. 하지만, 필요한 경우 동영상을 일시 정지되도록 설정할 수 있습니다.안드로이드 권한 요청이 필요한 API로 READ_PHONE_STATE가 필요 권한입니다.
fun setAutoResumeVideoOnCallEnded(isAutoResumeVideoOnCallEnded: Boolean)Parameter name | Type | Description |
|---|---|---|
isAutoResumeVideoOnCallEnded | Boolean |
|
Sample code
ShopLive.setAutoResumeVideoOnCallEnded(true)적용 가이드: 통화 연결로 인한 인터럽트
ShopLive.setShareScheme
공유하기를 선택했을 때 전달할 URL 또는 scheme을 설정합니다.
fun setShareScheme(shareUrl: String)Parameter name | Type | Description |
|---|---|---|
shareUrl | String | 공유할 |
Sample code
val scheme = "shoplive://live" // or "https://shoplive.cloud/live"
ShopLive.setShareScheme(scheme)적용 가이드: 방송 링크 공유하기
ShopLive.setLoadingProgressColor
동영상 로딩 프로그레스 바 색을 설정합니다.
fun setLoadingProgressColor(@ColorInt colorInt: Int)Parameter name | Type | Description |
|---|---|---|
colorInt | ColorInt | 프로그레스 바에 설정할 색상 |
Sample code
ShopLive.setLoadingProgressColor(Color.WHITE)적용 가이드: 프로그레스 바 설정하기
ShopLive.setLoadingAnimation
동영상 로딩 프로그레스 바를 이미지 애니메이션으로 설정합니다.
fun setLoadingAnimation(animationDrawable: Int)Parameter name | Type | Description |
|---|---|---|
animationDrawable | Int | 이미지 배열 리소스 |
Sample code
// 이미지 애니메이션 설정
ShopLive.setLoadingAnimation(R.drawable.progress_animation)
// 이미지 애니메이션 해제
ShopLive.setLoadingAnimation(0)적용 가이드: 프로그레스 바 설정하기
ShopLive.setChatViewTypeface
채팅 폰트와 채팅 전송 버튼 폰트를 설정합니다.
채팅 폰트와 채팅 전송 버튼 폰트를 모두 적용하려면
setChatViewTypeface(typeface)함수를 호출합니다.
fun setChatViewTypeface(typeface: Typeface)Parameter name | Type | Description |
|---|---|---|
typeface | Typeface | 채팅 폰트와 채팅 전송 버튼 폰트를 공통으로 설정할 폰트 |
Sample code
val nanumGothic = resources.getFont(R.font.nanumgothic)
val nanumGothicBold = resources.getFont(R.font.nanumgothicbold)
ShopLive.setChatViewTypeface(nanumGothic)적용 가이드: 채팅 폰트 변경하기
ShopLive.setEnterPipModeOnBackPressed
동영상 시청 중, 뒤로 버튼을 선택(탭) 하여 화면을 빠져 나가면, 동영상이 종료됩니다. 하지만, 이 옵션을 사용하여 PIP 화면 모드로 전환하여 계속 동영상을 시청하도록 설정할 수 있습니다.
fun setEnterPipModeOnBackPressed(isEnterPipModeOnBackPressed: Boolean)Parameter name | Type | Description |
|---|---|---|
isEnterPipModeOnBackPressed | Boolean |
|
Sample code
ShopLive.setEnterPipModeOnBackPressed(true)ShopLive.close
시청 중인 방송을 종료합니다.
fun close()Sample code
ShopLive.close()ShopLive.setAutoCloseWhenAppDestroyed
루트 액티비티가 종료되어도 방송이 종료되지 않도록 설정할 수 있습니다.
이 옵션을 사용하는 이유는 Intent.FLAG_ACTIVITY_NEW_TASK 옵션을 사용하여 루트 액티비티를 다시 실행시킬 때 방송이 종료될 수 있으므로 앱이 종료되는 적절한 시점에 ShopLive.close 함수를 직접 호출하여 종료할 수 있도록 하기 위한 것입니다.
기본값:
자동 종료설정하지 않으면, 앱이 종료될 때 방송이 함께 종료됩니다.
fun setAutoCloseWhenAppDestroyed(isAutoClose: Boolean)Parameter name | Type | Description |
|---|---|---|
isAutoClose | Boolean |
|
Sample code
ShopLive.setAutoCloseWhenAppDestroyed(false)ShopLive.startPictureInPicture
전체 화면 모드에서 PIP 화면 모드로 전환합니다.
fun startPictureInPicture()Sample code
ShopLive.startPictureInPicture()적용 가이드: PIP(Picture-in-Picture)로 전환하기
ShopLive.stopPictureInPicture
PIP 화면 모드를 전체 화면 모드로 전환합니다.
fun stopPictureInPicture()Sample code
ShopLive.stopPictureInPicture()적용 가이드: PIP(Picture-in-Picture)로 전환하기
ShopLive.getStatus
현재 Shoplive Player 화면 상태입니다.
fun getStatus(): Statusenum Status
Value | Description |
|---|---|
None | 상태 없음 |
InAppPIP | Preview 모드 |
PIP | PIP 모드 |
Full | 전체 화면 모드 |
Sample code
ShopLive.getStatus()ShopLive.isShowingPreviewPopup
현재 Shoplive Preview 진입에 성공했을 때 전달되는 정보입니다.
fun isShowingPreviewPopup(): BooleanSample code
ShopLive.isShowingPreviewPopup()ShopLive.isSuccessCampaignJoin
방송 진입에 성공했을 때 전달되는 정보입니다.
fun isSuccessCampaignJoin(): BooleanSample code
ShopLive.isSuccessCampaignJoin()ShopLive.sendCommandMessage
서버로 command와 payload를 전달합니다. 사전 정의된 형식의 command, payload 를 전달할 수 있습니다. (또는, Shoplive와 협의하여 command와 payload를 정의할 수 있습니다.)
fun sendCommandMessage(command: String, payload: Map<String, Any?>)Parameter name | Type | Description |
|---|---|---|
command | String | 사전 정의된 |
payload | Map<String, Any?> | 사전 정의된 |
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
Shoplive Player를 시작할 때 사운드가 켜지도록 하거나 음소거하도록 설정합니다. (기본값: 사운드가 켜진 상태로 Shoplive Player를 시작합니다.)
fun setMuteWhenPlayStart(isMute: Boolean)Parameter name | Type | Description |
|---|---|---|
isMute | Boolean | 음소거 설정 여부
|
Sample code
// Shoplive Player를 시작할 때 음소거하도록 설정
ShopLive.setMuteWhenPlayStart(true)
//Shoplive Player를 시작할 때 사운드가 켜지도록 설정
ShopLive.setMuteWhenPlayStart(false)ShopLive.setAppVersion
앱 버전을 설정합니다. API를 호출하지 않아도 기본값으로 앱 버전을 읽고 서버로 전달됩니다. 이 기능을 사용하려면 Shoplive 담당자에게 문의하세요.
fun setAppVersion(appVersion: String)Parameter name | Type | Description |
|---|---|---|
appVersion | String | 앱 버전 |
Sample code
val appVersion: String = “1.0.0”
ShopLive.setAppVersion(appVersion)ShopLive.setVisibleStatusBar
화면의 StatusBar의 숨길 수 있습니다.
fun setVisibleStatusBar(isVisible: Boolean)Parameter name | Type | Description |
|---|---|---|
isVisible | Boolean | 상태바의 숨김 유무를 설정합니다.
|
Sample code
ShopLive.setVisibleStatusBar(true)ShopLive.setSystemBarColor
화면의 SystemBar 색상을 변경할 수 있습니다.
fun setSystemBarColor(data: ShopLivePlayerSystemBarColorData)Parameter name | Type | Description |
|---|---|---|
data | ShopLivePlayerSystemBarColorData | SystemBar 색상 data |
ShopLivePlayerSystemBarColorData
Property name | Type | Description |
|---|---|---|
statusBarColor | ColorInt | StatusBar 색상을 변경할 수 있습니다. 기본값: |
navigationBarColor | ColorInt | SystemBar 색상을 변경할 수 있습니다. 기본값: |
Sample code
// StatusBar 투명 example
ShopLive.setSystemBarColor(ShopLivePlayerSystemBarColorData().apply {
statusBarColor = Color.TRANSPARENT
})ShopLive.setSoundFocusHandling
영상 재생중에 전화가 오거나 다른 앱의 플레이어 사용으로 인해 사운드를 빼앗긴 경우 이벤트를 받아 직접 처리할 수 있습니다.
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
Shoplive Player 화면에 사용자의 DialogFragment를 표시하기 위해 사용합니다.
fun showDialogFragment(dialogFragment: DialogFragment)Parameter name | Type | Description |
|---|---|---|
dialogFragment | DialogFragment | 사용자의 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
ShopLive.showDialogFragment(fragment)로 띄운 다이얼로그를 종료합니다.
fun closeDialogFragment()Sample code
ShopLive.closeDialogFragment()ShopLive.setPlayerScreenCaptureEnabled
방송 화면의 스크린 샷을 막을 수 있습니다.
fun setPlayerScreenCaptureEnabled(isEnabled: Boolean)Parameter name | Type | Description |
|---|---|---|
isEnabled | Boolean | 화면캡쳐기능의 활성화 여부를 설정합니다.
|
Sample code
// 화면 캡쳐 비활성화
ShopLive.setPlayerScreenCaptureEnabled(false)
// 화면 캡쳐 활성화
ShopLive.setPlayerScreenCaptureEnabled(true)ShopLive.setMixWithOthers
외부 오디오가 재생될 때, 방송의 오디오를 설정할 수 있습니다.
fun setMixWithOthers(isMixAudio: Boolean)Parameter name | Type | Description |
|---|---|---|
isMixAudio | Boolean | 기본값:
|
Sample code
// 외부 오디오가 재생되면 Player는 일시정지
ShopLive.setMixWithOthers(false)
// 외부 오디오와 함께 방송 시청
ShopLive.setMixWithOthers(true)ShopLive.setUtmSource
UTM Source를 tracking 할 수 있습니다. 데이터는 데이터 인사이트에서 확인 할 수 있습니다.
fun setUtmSource(utmSource: String)Parameter name | Type | Description |
|---|---|---|
utmSource | String | 해당 유입이 어디에서 발생하였는지를 전달해줍니다. |
Sample code
ShopLive.setUtmSource(“{utm_source}”)ShopLive.setUtmMedium
UTM Medium를 tracking 할 수 있습니다. 데이터는 데이터 인사이트에서 확인 할 수 있습니다.
fun setUtmMedium(utmMedium: String)Parameter name | Type | Description |
|---|---|---|
utmMedium | String | 해당 유입이 어떻게 발생하였는지를 전달해줍니다. 구글은 medium 파라미터를 유입이 유도된 마케팅 방식을 지칭하도록 세팅하는 것을 권장하고 있습니다. (ex. cpc, banner, email, blog, social etc.) |
Sample code
ShopLive.setUtmMedium(“{utm_medium}”)ShopLive.setUtmCampaign
UTM Campaign를 tracking 할 수 있습니다. 데이터는 데이터 인사이트에서 확인 할 수 있습니다.
fun setUtmCampaign(utmCampaign: String)Parameter name | Type | Description |
|---|---|---|
utmCampaign | String | 어떤 광고의 캠페인으로 유입이 발생하였는지를 전달해줍니다. Campaign Name, Campaign Term, Campaign Content로 나눠서 만들 수 있습니다. |
Sample code
ShopLive.setUtmCampaign(“{utm_campaign}”)ShopLive.setUtmContent
UTM Content를 tracking 할 수 있습니다. 데이터는 데이터 인사이트에서 확인 할 수 있습니다.
fun setUtmContent(utmContent: String)Parameter name | Type | Description |
|---|---|---|
utmContent | String | 해당 유입이 어떤 내용을 가진 포스팅/광고에 의해서 발생하였는지를 전달해줍니다. 주로 campaign 파라미터의 하위 구분으로 자주 활용됩니다. |
Sample code
ShopLive.setUtmContent(“{utm_content}”)ShopLive.addParameter
플레이어를 실행하기 전에 커스텀 데이터를 추가할 수 있습니다.
fun addParameter(key: String, value: String)Parameter name | Type | Description |
|---|---|---|
key | String | 추가 적용할 커스텀 파라미터 key |
value | String | 추가 적용할 커스텀 파라미터 value |
Sample code
ShopLive.addParameter(“{key}”, “{value}”)ShopLive.removeParameter
플레이어를 실행하기 전에 addParameter로 추가했던 커스텀 데이터를 삭제합니다.
fun removeParameter(key: String)Parameter name | Type | Description |
|---|---|---|
key | String | 삭제할 파라미터 key |
Sample code
ShopLive.removeParameter(“{key}”)ShopLive.setNextActionOnHandleNavigation
사용자가 상품, 공지사항, 배너 등 링크를 선택하였을 때, Shoplive Player의 다음 동작을 설정합니다.
fun setNextActionOnHandleNavigation(type: ActionType)enum ActionType
Value | Description |
|---|---|
PIP | PIP 전환 |
KEEP | 상태 유지 |
CLOSE | 종료 |
Sample code
ShopLive.setNextActionOnHandleNavigation(ActionType.PIP)ShopLive.setEndpoint
Shoplive Player의 Web Landing 페이지가 아닌 특정 Landing 페이지 또는 URL에서 Shoplive 서비스를 사용해야 할 때 사용합니다. 예를 들어, 보안으로 인해 Shoplive Landing 페이지를 사용할 수 없는 경우, 특정 도메인으로 Landing 페이지를 생성할 수 있습니다.
Shoplive Player의 Web Landing 페이지는 Shoplive와 협의 후 적용할 수 있습니다.
플레이어를 실행하기 전에 addParameter로 추가했던 커스텀 데이터를 삭제합니다.
fun setEndpoint(url: String)Parameter name | Type | Description |
|---|---|---|
url | String | Shoplive Player의 Web Landing url |
Sample code
ShopLive.setEndpoint("https://www.your_landingpage.com/")ShopLive.setResizeMode
영상의 종횡비를 유지할 수 있습니다. (Default: ShopLiveResizeMode.CENTER_CROP)
fun setResizeMode(resizeMode: ShopLiveResizeMode)