feat: add native hls media + refactor (#1154)

This commit is contained in:
Wesley Luyten
2026-03-30 20:13:19 -05:00
committed by GitHub
parent 0433722ee4
commit 1b2afc6e41
24 changed files with 552 additions and 200 deletions
@@ -0,0 +1,14 @@
import { NativeHlsVideo } from '../../media/native-hls-video';
import { safeDefine } from '../safe-define';
export class NativeHlsVideoElement extends NativeHlsVideo {
static readonly tagName = 'native-hls-video';
}
safeDefine(NativeHlsVideoElement);
declare global {
interface HTMLElementTagNameMap {
[NativeHlsVideoElement.tagName]: NativeHlsVideoElement;
}
}
-1
View File
@@ -1,5 +1,4 @@
// Core
export type { Delegate } from '@videojs/core';
export { DelegateMixin } from '@videojs/core';
export * from '@videojs/core/dom';
@@ -0,0 +1,18 @@
import { NativeHlsCustomMedia, NativeHlsMediaDelegate } from '@videojs/core/dom/media/native-hls';
import { MediaAttachMixin } from '../../store/media-attach-mixin';
import { MediaPropsMixin } from '../../utils/media-props-mixin';
export class NativeHlsVideo extends MediaPropsMixin(MediaAttachMixin(NativeHlsCustomMedia), NativeHlsMediaDelegate) {
constructor() {
super();
this.attach(this.target);
}
disconnectedCallback(): void {
super.disconnectedCallback?.();
if (!this.hasAttribute('keep-alive')) {
this.destroy();
}
}
}
@@ -10,6 +10,7 @@ function buildAttrPropMap(DelegateClass: AnyClass): Map<string, string> {
const map = new Map<string, string>();
for (let proto = DelegateClass.prototype; proto && proto !== Object.prototype; proto = Object.getPrototypeOf(proto)) {
for (const key of Object.getOwnPropertyNames(proto)) {
if (key.startsWith('_')) continue;
const desc = Object.getOwnPropertyDescriptor(proto, key);
if (desc?.set) map.set(camelToKebab(key), key);
}