2 lines
2.7 KiB
JavaScript
2 lines
2.7 KiB
JavaScript
import{m as h,B as p,G as u,P as m,W as v,j as g,n as b}from"./index-97b4652c.js";import"./vuetify-52f40ce5.js";import"./overlayscrollbars-44d87bcf.js";import"./echarts-9bc570b0.js";var f=Object.defineProperty,d=Object.getOwnPropertyDescriptor,n=(e,t,s,a)=>{for(var i=a>1?void 0:a?d(t,s):t,l=e.length-1,o;l>=0;l--)(o=e[l])&&(i=(a?o(t,s,i):o(i))||i);return a&&i&&f(t,s,i),i};let r=class extends h(p,u){constructor(){super(...arguments),this.aspectRatio=null,this.isVisible=!1,this.isVisibleViewport=!1,this.isVisibleDocument=!0}get url(){var t;return this.convertUrl((t=this.camSettings)==null?void 0:t.stream_url,this.printerUrl)}get webcamStyle(){var s,a,i;const t={transform:this.generateTransform((s=this.camSettings.flip_horizontal)!=null?s:!1,(a=this.camSettings.flip_vertical)!=null?a:!1,(i=this.camSettings.rotation)!=null?i:0),aspectRatio:1.7777777777777777,maxHeight:window.innerHeight-155+"px",maxWidth:"auto"};return this.aspectRatio&&(t.aspectRatio=this.aspectRatio,t.maxWidth=(window.innerHeight-155)*this.aspectRatio+"px"),t}mounted(){document.addEventListener("visibilitychange",this.documentVisibilityChanged)}beforeDestroy(){document.removeEventListener("visibilitychange",this.documentVisibilityChanged),this.stopStream()}startStream(){this.isVisible||this.$refs.webcamUv4lMjpegImage&&this.$refs.webcamUv4lMjpegImage.setAttribute("src",this.url)}stopStream(){this.$refs.webcamUv4lMjpegImage&&(this.$refs.webcamUv4lMjpegImage.removeAttribute("src"),URL.revokeObjectURL(this.url))}documentVisibilityChanged(){const t=document.visibilityState;this.isVisibleDocument=t==="visible",this.isVisibleDocument||this.stopStream(),this.visibilityChanged()}viewportVisibilityChanged(t){this.isVisibleViewport=t,this.visibilityChanged()}visibilityChanged(){if(this.isVisibleViewport&&this.isVisibleDocument){this.startStream();return}this.stopStream()}onload(){this.aspectRatio===null&&this.$refs.webcamUv4lMjpegImage&&(this.aspectRatio=this.$refs.webcamUv4lMjpegImage.naturalWidth/this.$refs.webcamUv4lMjpegImage.naturalHeight)}async urlChanged(){await this.stopStream(),await this.startStream()}};n([m({required:!0})],r.prototype,"camSettings",2);n([m({default:null})],r.prototype,"printerUrl",2);n([v("url")],r.prototype,"urlChanged",1);r=n([g],r);var _=function(){var e=this,t=e.$createElement,s=e._self._c||t;return s("div",{staticClass:"d-flex justify-center"},[s("img",{directives:[{name:"observe-visibility",rawName:"v-observe-visibility",value:e.viewportVisibilityChanged,expression:"viewportVisibilityChanged"}],ref:"webcamUv4lMjpegImage",staticClass:"webcamImage",style:e.webcamStyle,on:{load:e.onload}})])},y=[];const c={};var w=b(r,_,y,!1,j,"3177fd01",null,null);function j(e){for(let t in c)this[t]=c[t]}const M=function(){return w.exports}();export{M as default};
|