Video player
Video upload and playback are handled by the custom elements created by the Elice video player's embed.js. The SDK only passes along that script's URL and the token.
import { loadScript } from '@eliceio/cdk';
if (sdk.videoPlayerUrl) {
const { Video, VideoUpload } = await loadScript(sdk.videoPlayerUrl, 'EliceVideoPlayer');
let token = sdk.accessToken; // 플레이어 요소에 넘김
const unsubscribe = sdk.onAccessTokenChange(next => {
token = next; // 새 토큰을 플레이어 요소에 넘김
});
}
| Name | Description |
|---|---|
sdk.videoPlayerUrl | The embed.js URL for that environment, passed by LXP in the fragment videoPlayerUrl. null if absent |
sdk.accessToken | The token the SDK uses for the server. null before init() or in previews without a token |
sdk.onAccessTokenChange(listener) | Calls listener each time LXP sends a new token. Call the returned function to stop receiving |
loadScript(src, namespace) | Loads a regular <script> and returns window[namespace] |
loadScriptloads the samesrc·namespaceonly once, and returns immediately if it is already loaded.- If loading fails it throws
script_load_failed; if it loads butwindow[namespace]is missing, it throwsscript_namespace_not_found. Calling it again retries. - The token is short-lived and changes. Update the token passed to the player with
onAccessTokenChange(Token refresh and session expiry).