메서드

TV SDK에서 ref를 통해 플레이어를 제어하는 메서드를 안내합니다.

사용법

import React, { useRef } from 'react';
import { View, Pressable, Text, StyleSheet } from 'react-native';
import { VpePlayer } from '@sgrsoft/vpe-reactnative-tv-sdk';
import type { PlayerHandle } from '@sgrsoft/vpe-reactnative-tv-sdk';

export default function PlayerWithControls() {
    const playerRef = useRef<PlayerHandle>(null);

    return (
        <View style={styles.container}>
            <VpePlayer
                ref={playerRef}
                accessKey="YOUR_ACCESS_KEY"
                options={{
                    playlist: [{ file: 'https://example.com/video.m3u8' }],
                }}
                onBack={() => { /* 뒤로가기 */ }}
            />

            <View style={styles.controls}>
                <Pressable onPress={() => playerRef.current?.play()}>
                    <Text>재생</Text>
                </Pressable>
                <Pressable onPress={() => playerRef.current?.pause()}>
                    <Text>일시정지</Text>
                </Pressable>
                <Pressable onPress={() => playerRef.current?.currentTime(30)}>
                    <Text>30초로 이동</Text>
                </Pressable>
                <Pressable onPress={() => playerRef.current?.next()}>
                    <Text>다음 영상</Text>
                </Pressable>
            </View>
        </View>
    );
}

const styles = StyleSheet.create({
    container: { flex: 1, backgroundColor: '#000' },
    controls: { flexDirection: 'row', gap: 8, padding: 16 },
});

메서드 목록

메서드설명TV 동작
play()재생정상 동작
pause()일시정지정상 동작
mute()음소거 토글정상 동작
prev() / next()이전/다음 트랙정상 동작
currentTime(time)시킹 (초)정상 동작
volume(vol)볼륨 설정no-op (시스템 볼륨 사용)
uiHidden() / uiVisible()UI 숨김/표시정상 동작
controlBarActive() / controlBarDeactive()컨트롤바 활성화/비활성화정상 동작
tokenChange(token)DRM 토큰 갱신정상 동작
layout(layout, merge)레이아웃 변경정상 동작
changePlayMode(mode)VOD/Live 모드 전환정상 동작
addNextSource(source)다음 소스 추가정상 동작
addPrevSource(source)이전 소스 추가정상 동작
isSeeking()시킹 상태 조회정상 동작
fullscreen()전체화면no-op (항상 전체화면)
pip()PiPno-op (TV 미지원)

동적 플레이리스트 추가

// 단일 영상 추가
playerRef.current?.addNextSource({
    file: 'https://example.com/new_video.m3u8',
    description: { title: '새로운 영상' },
});

// 여러 영상 동시 추가
playerRef.current?.addPrevSource([
    { file: 'https://example.com/video_1.mp4' },
    { file: 'https://example.com/video_2.mp4' },
]);
TV SDK