(props, context)
| 15 | // https://github.com/vuejs/core/pull/2693 |
| 16 | // slots: Object as () => { player: VideoJsPlayer; state: DeepReadonly<PlayerState> }, |
| 17 | setup(props, context) { |
| 18 | const { class: initClassName, ...rawProps } = toRaw(props) |
| 19 | const mounted = shallowRef(false) |
| 20 | const videoElement = shallowRef<HTMLVideoElement | null>(null) |
| 21 | const playerResult = shallowRef<PlayerResult | null>(null) |
| 22 | const videoJsPlayer = computed(() => { |
| 23 | return playerResult.value ? playerResult.value.player : null |
| 24 | }) |
| 25 | |
| 26 | const state = ref<PlayerState | null>(null) |
| 27 | const readOnlyState = computed<DeepReadonly<PlayerState> | null>(() => { |
| 28 | return state.value ? readonly(state.value) : null |
| 29 | }) |
| 30 | |
| 31 | onMounted(() => { |
| 32 | // Create player. |
| 33 | const playerRes = createPlayer({ |
| 34 | element: videoElement.value!, |
| 35 | props: rawProps, |
| 36 | onEvent: context.emit |
| 37 | }) |
| 38 | |
| 39 | // Sync Video.js config change to update:prop event. |
| 40 | bindPropUpdateEvent({ |
| 41 | player: playerRes.player, |
| 42 | onEvent: context.emit |
| 43 | }) |
| 44 | |
| 45 | // Sync Vue class name to Video.js container. |
| 46 | watch( |
| 47 | () => props.class, |
| 48 | (newClassName, oldClassName) => { |
| 49 | const ocn = normalizeClass(oldClassName) |
| 50 | const ncn = normalizeClass(newClassName) |
| 51 | playerRes.updateClassNames(ocn, ncn) |
| 52 | }, |
| 53 | { immediate: true } |
| 54 | ) |
| 55 | |
| 56 | // Sync fallback options to Video.js config. |
| 57 | watch( |
| 58 | () => props.options, |
| 59 | (newOptions) => playerRes.updateOptions(newOptions ?? {}), |
| 60 | { deep: true } |
| 61 | ) |
| 62 | |
| 63 | // Sync component props to Video.js config. |
| 64 | propKeys |
| 65 | .filter((key) => key !== 'options') |
| 66 | .forEach((key) => { |
| 67 | watch( |
| 68 | () => props[key], |
| 69 | (newValue) => playerRes.updatePropOption(key, newValue), |
| 70 | { deep: true } |
| 71 | ) |
| 72 | }) |
| 73 | |
| 74 | // Create player state. |
nothing calls this directly
no test coverage detected