diff --git a/cast/static/cast/vite/manifest.json b/cast/static/cast/vite/manifest.json index 20373da1..ec2f188c 100644 --- a/cast/static/cast/vite/manifest.json +++ b/cast/static/cast/vite/manifest.json @@ -1,6 +1,6 @@ { "src/audio/podlove-player.ts": { - "file": "podlovePlayer-vU4Jjjws.js", + "file": "podlovePlayer-Cn4SwLmX.js", "name": "podlovePlayer", "src": "src/audio/podlove-player.ts", "isEntry": true diff --git a/cast/static/cast/vite/podlovePlayer-vU4Jjjws.js b/cast/static/cast/vite/podlovePlayer-Cn4SwLmX.js similarity index 80% rename from cast/static/cast/vite/podlovePlayer-vU4Jjjws.js rename to cast/static/cast/vite/podlovePlayer-Cn4SwLmX.js index fb5d6115..b0a187f6 100644 --- a/cast/static/cast/vite/podlovePlayer-vU4Jjjws.js +++ b/cast/static/cast/vite/podlovePlayer-Cn4SwLmX.js @@ -1,4 +1,4 @@ -class d extends HTMLElement{constructor(){super(),this.observer=null,this.shadow=this.attachShadow({mode:"open"})}connectedCallback(){this.renderPlaceholder(),this.observeElement()}disconnectedCallback(){this.observer&&this.observer.disconnect()}renderPlaceholder(){const e=document.createElement("div");e.classList.add("podlove-player-container");const t=document.createElement("style");t.textContent=` +class d extends HTMLElement{constructor(){super(),this.observer=null,this.shadow=this.attachShadow({mode:"open"})}connectedCallback(){this.renderPlaceholder(),document.readyState==="complete"?this.observeElement():window.addEventListener("load",()=>{this.observeElement()},{once:!0})}disconnectedCallback(){this.observer&&this.observer.disconnect()}renderPlaceholder(){const e=document.createElement("div");e.classList.add("podlove-player-container");const t=document.createElement("style");t.textContent=` .podlove-player-container { width: 100%; max-width: 936px; diff --git a/javascript/src/audio/podlove-player.ts b/javascript/src/audio/podlove-player.ts index 57a0c428..901e1bd9 100644 --- a/javascript/src/audio/podlove-player.ts +++ b/javascript/src/audio/podlove-player.ts @@ -8,7 +8,16 @@ class PodlovePlayerElement extends HTMLElement { connectedCallback() { this.renderPlaceholder(); - this.observeElement(); + + if (document.readyState === 'complete') { + // The page is already fully loaded + this.observeElement(); + } else { + // Wait for the 'load' event before initializing + window.addEventListener('load', () => { + this.observeElement(); + }, { once: true }); + } } disconnectedCallback() {