mirror of
https://github.com/zoriya/v10.git
synced 2026-08-16 02:45:09 +00:00
fix(core): fix media proxy for React (#1169)
This commit is contained in:
@@ -16,7 +16,7 @@ export const ProxyMixin = <T extends EventTarget>(
|
||||
PrimaryClass: AnyConstructor<T>,
|
||||
...AdditionalClasses: AnyConstructor<EventTarget>[]
|
||||
) => {
|
||||
class MediaProxy extends EventTarget {
|
||||
class MediaProxy {
|
||||
#target: EventTarget | null = null;
|
||||
|
||||
get target() {
|
||||
@@ -47,6 +47,26 @@ export const ProxyMixin = <T extends EventTarget>(
|
||||
if (!this.#target) return;
|
||||
this.#target = null;
|
||||
}
|
||||
|
||||
addEventListener(
|
||||
type: string,
|
||||
listener: EventListenerOrEventListenerObject,
|
||||
options?: boolean | AddEventListenerOptions
|
||||
): void {
|
||||
this.#target?.addEventListener(type, listener, options);
|
||||
}
|
||||
|
||||
removeEventListener(
|
||||
type: string,
|
||||
listener: EventListenerOrEventListenerObject,
|
||||
options?: boolean | EventListenerOptions
|
||||
): void {
|
||||
this.#target?.removeEventListener(type, listener, options);
|
||||
}
|
||||
|
||||
dispatchEvent(event: Event): boolean {
|
||||
return this.#target?.dispatchEvent(event) ?? false;
|
||||
}
|
||||
}
|
||||
|
||||
for (const Class of [PrimaryClass, ...AdditionalClasses]) {
|
||||
|
||||
@@ -47,6 +47,14 @@ export class NativeHlsMediaDelegate extends EventTarget {
|
||||
|
||||
attach(target: HTMLMediaElement) {
|
||||
this.#target = target;
|
||||
|
||||
if (this.preload !== this.#target.preload) {
|
||||
this.#target.preload = this.preload;
|
||||
}
|
||||
|
||||
if (this.src !== this.#target.src) {
|
||||
this.#target.src = this.src;
|
||||
}
|
||||
}
|
||||
|
||||
detach() {
|
||||
|
||||
Reference in New Issue
Block a user