const template = document.createElement("template");
template.innerHTML = `
`;
class mplayer extends HTMLElement {
constructor() {
super();
this._shadowRoot = this.attachShadow({ mode: "open" });
this._shadowRoot.appendChild(template.content.cloneNode(true));
this.$mplayer = this._shadowRoot.querySelector(".mplayer");
}
static get observedAttributes() {
return ["title", "artist", "media_url", "cover_url"];
}
attributeChangedCallback(name, oldVal, newVal) {
if (oldVal != newVal) {
this[name] = newVal;
this.render();
}
}
render() {
this.$mplayer.querySelector(".title").innerHTML = this.title;
this.$mplayer.querySelector(".artist").innerHTML = this.artist;
this.$mplayer.querySelector(".player").src = this.media_url;
this.$mplayer.querySelector(".coverContainer > img").src = this.cover_url;
}
}
window.customElements.define("wc-mplayer", mplayer);