Super Media Element
A custom element that helps save alienated player API's in bringing back their true inner
HTMLMediaElement API,
or to extend a native media element like <audio>
or <video>
.
Usage
import { SuperVideoElement } from 'super-media-element';
class MyVideoElement extends SuperVideoElement {
static observedAttributes = ['color', ...SuperVideoElement.observedAttributes];
static skipAttributes = ['src'];
async attributeChangedCallback(attrName, oldValue, newValue) {
if (attrName === 'color') {
this.api.color = newValue;
}
super.attributeChangedCallback(attrName, oldValue, newValue);
}
async load() {
this.api = new VideoPlayer();
}
get nativeEl() {
return this.querySelector('.loaded-video-element');
}
}
if (!globalThis.customElements.get('my-video')) {
globalThis.customElements.define('my-video', MyVideoElement);
}
export { MyVideoElement };
Related