import{View}from"./base.mjs";import{waitFor,isEmpty}from"../base/helpers.mjs";import{ElementBuilder}from"../base/builder.mjs";const E=new ElementBuilder;class VideoView extends View{static tagName="enfugue-video-view";constructor(e,i){super(e),this.loaded=!1,this.loadedCallbacks=[],this.setVideo(i)}onLoad(e){this.loaded?e(this):this.loadedCallbacks.push(e)}waitForLoad(){return waitFor((()=>this.loaded))}setVideo(e){this.src!==e&&(this.loaded=!1,this.src=e,this.video=document.createElement("video"),this.video.onloadedmetadata=()=>this.videoLoaded(),this.video.autoplay=!0,this.video.loop=!0,this.video.muted=!0,this.video.controls=!0,this.video.src=e)}videoLoaded(){this.loaded=!0,this.width=this.video.videoWidth,this.height=this.video.videoHeight;for(let e of this.loadedCallbacks)e()}async build(){let e=await super.build();return e.content(this.video),e}}class VideoPlayerView extends VideoView{setVideo(e){super.setVideo(e),this.video.controls=!0}async build(){return await super.build()}}export{VideoView,VideoPlayerView};
