API - Play

ShopLive.init

Shoplive Android SDK를 초기화합니다.

void init(@NonNull Application app)
매개변수설명
appApplication 인스턴스

샘플 코드

public class application extends Application {
    ...
    @Override
    public void onCreate() {
        // Shoplive Android SDK 인스턴스 초기화
        ShopLive.init(this);
    }
    ...
}

ShopLive.setAccessKey

Shoplive Android SDK를 사용할 수 있도록 AccessKey를 설정합니다.

void setAccessKey(@NonNull String accessKey)
매개변수설명
accesskeyShopLive 담당자에게 받은 AccessKey

샘플 코드

ShopLive.setAccessKey("{AccessKey}");

ShopLive.play

CampaignKey를 사용하여 동영상을 재생합니다.

void play(@NonNull String campaignKey)
void play(@NonNull String campaignKey, Boolean keepWindowStateOnPlayExecuted)
매개변수설명
campaignKey재생할 동영상의 캠페인(방송) 키
재생할 동영상의 캠페인(방송) 키 없이 play 함수를 호출하면 기본 캠페인(방송)을 재생합니다.
keepWindowStateOnPlayExecuted재생중인 플레이어의 실행 모드(pip, fullscreen)을 유지한 상태로 재생을 시작할 지 여부. 기본값(false)
true: 재생중인 플레이어의 실행 모드를 유지합니다.
false: fullscreen으로 실행됩니다.

샘플 코드

ShopLive.play("{campaignKey}");
// or
ShopLive.play("{campaignKey}", false or true); // 기본값 false

ShopLive.showPreview

캠페인(방송) 키를 사용하여 미리보기 뷰로 영상을 무음 재생합니다.
isOsPiptrue로 설정하고 방송 화면에 진입하면 PIP 화면 모드로 전환됩니다.
안드로이드 권한 요청이 필요한 API입니다.

void showPreview(@NonNull String campaignKey)
// 필요 권한: 다른 앱 위에 표시
void showPreview(@NonNull String campaignKey, Boolean isOsPip)
매개변수설명
campaignKey캠페인(방송) 키
isOsPipOS PIP로 전환 여부
true: 방송 화면 진입 후 PIP 화면 모드로 전환

isOsPiptrue만 설정할 수 있습니다.


샘플 코드

// 일반 View로 미리보기를 재생합니다.
ShopLive.showPreview("{CampaignKey}");

// PIP View로 미리보기를 재생합니다.
ShopLive.showPreview("{CampaignKey}", true);

ShopLive.hidePreview

재생 중인 미리보기 화면을 숨깁니다.

void hidePreview()

샘플 코드

ShopLive.hidePreview();

ShopLive.resumePreview

숨겨진 미리보기 화면을 다시 표시합니다.

void resumePreview()

샘플 코드

ShopLive.resumePreview();

ShopLivePreview

ShopLive에서 제공하는 ShopLivePreview 또는 ShopLiveSwipePreview 컴포넌트를 통해서 프리뷰를 직접 구현할 수 있습니다.


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

미리보기 재생을 시작합니다.

fun start(accessKey: String?, campaignKey: String?)
매개변수설명
accessKey고객사 key
campaignKey방송 key

pause

미리보기를 일시정지 합니다.

fun pause()

play

일시정지 된 미리보기를 재생합니다.

fun play()

release

미리보기를 해제합니다.

fun release()

setLifecycleObserver

LifecyclerOwner를 등록하면 라이프 사이클에 맞게 미리보기 플레이어가 자동으로 play 또는 pause 할 수 있습니다.

fun setLifecycleObserver(owner: LifecycleOwner)
매개변수설명
ownerLifecycleOwner

setOnCloseLisstener

미리보기 종료 이벤트를 받을 수 있습니다.

fun setOnCloseLisstener(onCloseListener: OnCloseListener)

setOnDimensionRatioListener

미리보기 화면의 가로 세로 비율을 얻을 수 있습니다.

fun setOnDimensionRatioListener(onDimensionRatioListener: OnDimensionRatioListener)