UNPKG

@vime/core

Version:

Customizable, extensible, accessible and framework agnostic media player.

114 lines (113 loc) 2.44 kB
import { en } from './lang/en'; export const initialState = { theme: undefined, paused: true, playing: false, duration: -1, currentProvider: undefined, mediaTitle: undefined, currentSrc: undefined, currentPoster: undefined, textTracks: [], currentTextTrack: -1, audioTracks: [], currentAudioTrack: -1, isTextTrackVisible: true, shouldRenderNativeTextTracks: true, icons: 'vime', currentTime: 0, autoplay: false, ready: false, playbackReady: false, loop: false, muted: false, buffered: 0, playbackRate: 1, playbackRates: [1], playbackQuality: undefined, playbackQualities: [], seeking: false, debug: false, playbackStarted: false, playbackEnded: false, buffering: false, controls: false, isControlsActive: false, volume: 50, isFullscreenActive: false, aspectRatio: '16:9', viewType: undefined, isAudioView: false, isVideoView: false, mediaType: undefined, isAudio: false, isVideo: false, isMobile: false, isTouch: false, isSettingsActive: false, isLive: false, isPiPActive: false, autopause: true, playsinline: false, language: 'en', languages: ['en'], translations: { en }, i18n: en, }; const writableProps = new Set([ 'autoplay', 'autopause', 'aspectRatio', 'controls', 'theme', 'debug', 'paused', 'currentTime', 'language', 'loop', 'translations', 'playbackQuality', 'muted', 'playbackRate', 'playsinline', 'volume', 'isSettingsActive', 'isControlsActive', 'shouldRenderNativeTextTracks', ]); export const isReadonlyProp = (prop) => !writableProps.has(prop); export const isWritableProp = (prop) => writableProps.has(prop); /** * Player properties that should be reset when the media is changed. */ const resetableProps = new Set([ 'paused', 'currentTime', 'duration', 'buffered', 'seeking', 'playing', 'buffering', 'playbackReady', 'textTracks', 'currentTextTrack', 'audioTracks', 'currentAudioTrack', 'mediaTitle', 'currentSrc', 'currentPoster', 'playbackRate', 'playbackRates', 'playbackStarted', 'playbackEnded', 'playbackQuality', 'playbackQualities', 'mediaType', ]); export const shouldPropResetOnMediaChange = (prop) => resetableProps.has(prop); const playerWritableProps = new Set([ 'isMobile', 'isTouch', 'isFullscreenActive', ]); export const isPlayerWritableProp = (prop) => isWritableProp(prop) || playerWritableProps.has(prop);