UNPKG

@aidenlx/player

Version:

Headless web components that make integrating media on the a web a breeze.

50 lines (45 loc) 4.33 kB
import{a as M}from"./chunk.R7LWQQGW.js";import{b as E}from"./chunk.DZBVSYZM.js";import{a as s}from"./chunk.KCC3AAG2.js";import{G as P,a as o,b as v,f as n,ia as b,j as m,m as i,o as g,q as t,r,u as f,x as y,z as l}from"./chunk.PWTX2M5C.js";var p=class extends P{constructor(e,a,c){super(e,a);this.tt=c}get isFullscreen(){return this.isSupportedNatively?this.isNativeFullscreen:this.tt.isFullscreenMode}get isSupported(){return this.isSupportedNatively||this.isSupportedOnSafari}get isSupportedOnSafari(){return this.tt.isSupported}async ft(){return this.isSupportedNatively?super.ft():this.Js()}async Js(){return this.tt.setPresentationMode("fullscreen")}async gt(){return this.isSupportedNatively?super.gt():this.Xs()}async Xs(){return this.tt.setPresentationMode("inline")}pt(e){return this.isSupportedNatively?super.pt(e):this.isSupportedOnSafari?n(this.e,"vds-video-presentation-change",this.Jt.bind(this)):r}Jt(e){this.vt(e)}mt(e){return this.isSupportedNatively?super.mt(e):r}};var u=class{constructor(e){this.e=e;this.z=void 0;this.E=new m;let a=e.firstUpdated;e.firstUpdated=c=>{a?.call(e,c),this.E.add(this.Ys())},e.addController({hostDisconnected:this.Ee.bind(this)})}Ee(){this.setPresentationMode("inline"),this.E.empty()}get presentationMode(){return this.e.videoElement?.webkitPresentationMode}get isInlineMode(){return this.presentationMode==="inline"}get isPictureInPictureMode(){return this.presentationMode==="inline"}get isFullscreenMode(){return this.presentationMode==="fullscreen"}get isSupported(){return y(this.e.videoElement?.webkitSetPresentationMode)}setPresentationMode(e){this.e.videoElement?.webkitSetPresentationMode?.(e)}Ys(){return!this.isSupported||f(this.e.videoElement)?r:n(this.e.videoElement,"webkitpresentationmodechanged",this.Jt.bind(this))}Jt(e){g(this.e,e),this.e.dispatchEvent(i("vds-video-presentation-change",{detail:this.presentationMode,triggerEvent:e}))}};var S=b` :host { display: inline-block; contain: content; } :host([hidden]) { display: none; } video { display: inline-block; border-radius: inherit; vertical-align: middle; outline: 0; border: 0; user-select: none; -webkit-user-select: none; } video:not([width]) { width: 100%; } video:not([height]) { height: 100%; } `;var d=class extends M{constructor(){super(...arguments);this.presentationController=new u(this);this.fullscreenController=new p(this,this.screenOrientationController,this.presentationController)}static get styles(){return[S]}static get parts(){return["root","video"]}get poster(){return this.mediaState.currentPoster}set poster(e){this.Le.queue("current-poster",()=>{this.dispatchEvent(i("vds-poster-change",{detail:e})),this.requestUpdate()})}get mediaElement(){return this.Ze.value}get videoElement(){return this.mediaElement}get engine(){return this.mediaElement}get videoEngine(){return this.videoElement}connectedCallback(){super.connectedCallback(),this.dispatchEvent(i("vds-view-type-change",{detail:"video"}))}render(){return this.He()}He(){return v` <video part="${this.Zs()}" src="${t(this.Xt()?this.src:"")}" width="${l(this.width)}" height="${l(this.height)}" poster="${t(this.__canLoadPoster?this.poster:"")}" preload="${t(this.preload)}" crossorigin="${t(this.crossOrigin)}" controlslist="${t(this.controlsList)}" ?playsinline="${this.playsinline}" ?controls="${this.controls}" ?autopictureinpicture="${this.autoPiP}" ?disablepictureinpicture="${this.disablePiP}" ?disableremoteplayback="${this.disableRemotePlayback}" .defaultMuted="${this.defaultMuted??this.muted}" .defaultPlaybackRate="${this.defaultPlaybackRate??1}" ${E(this.Ze)} > ${this.vi()} </video> `}Zs(){return"media video"}Xt(){return this.canLoad}async handleMediaCanLoad(){await super.handleMediaCanLoad(),this.Xt()&&(this.requestUpdate(),await this.updateComplete,this.load())}async requestPictureInPicture(){return this.videoElement?.requestPictureInPicture()}};o([s({type:Boolean,attribute:"autopictureinpicture"})],d.prototype,"autoPiP",2),o([s({type:Boolean,attribute:"disablepictureinpicture"})],d.prototype,"disablePiP",2),o([s({reflect:!0})],d.prototype,"poster",1);export{d as a};