UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

6 lines (5 loc) 4.58 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.32/esri/copyright.txt for details. */ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import{watch as r,initial as l}from"../../core/reactiveUtils.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import{videoMetadataEntryId as o}from"../../layers/video/videoUtils.js";function a(e,t){const r={};for(const l of t){const t=e.get(l);t&&(r[t.name]=t.value)}return r}let n=class extends t{constructor(e){super(e),this.followingMode="follow-both",this.layer=null,this.seekLength=10,this.view=null}initialize(){this.addHandles([r((()=>this.layer),(e=>{e&&e.load().then((()=>this._followTelemetry())).catch((()=>{}))}),l),r((()=>[this.followingMode]),(()=>this._followTelemetry()),l)])}get _layerView(){return this.layer&&this.view?this.view.allLayerViews.find((e=>e.layer===this.layer))??null:null}get buffered(){return this.layer?.buffered||0}get currentTime(){return this.layer?.currentTime||0}get duration(){return this.layer?.duration||0}get ended(){return this.layer?.ended??!0}get metadata(){const e=this.layer?.metadata;return e?{missionInfo:a(e,[o.MissionId,o.PrecisionTimeStamp]),platformInfo:a(e,[o.PlatformTailNumber,o.PlatformTrueAirspeed,o.PlatformCallSign,o.PlatformDesignation,o.PlatformGroundRange]),frameInfo:a(e,[o.FrameCenterElevation,o.FrameCenterLatitude,o.FrameCenterLongitude])}:null}get playing(){return this.layer?.playing??!1}get state(){return this.layer?.loadError?"error":this.layer?.state}play(){this.layer?.play()}pause(){this.layer?.pause()}seekBackward(){if(this.layer){const e=this.layer.currentTime-this.seekLength;e<=0?this.layer.reset():this.layer.setCurrentTime(e)}}seekForward(){if(this.layer){const e=this.layer.currentTime+this.seekLength;e>=this.layer.duration?this.layer.reset():this.layer.setCurrentTime(e)}}seekToBeginning(){this.layer?.setCurrentTime(0)}seekToEnding(){this.layer?.setCurrentTime(this.layer.duration)}seekTo(e){this.layer?.setCurrentTime(e)}toggleSensorDisplay(){this._layerView?.visibleTelemetryElements&&(this._layerView.visibleTelemetryElements.sensorLocation=!this._layerView.visibleTelemetryElements.sensorLocation)}toggleSensorSightLineDisplay(){this._layerView?.visibleTelemetryElements&&(this._layerView.visibleTelemetryElements.lineOfSight=!this._layerView.visibleTelemetryElements.lineOfSight)}toggleFrameDisplay(){this._layerView?.visibleTelemetryElements&&(this._layerView.visibleTelemetryElements.frame=!this._layerView.visibleTelemetryElements.frame)}toggleSensorTrailDisplay(){this._layerView?.visibleTelemetryElements&&(this._layerView.visibleTelemetryElements.sensorTrail=!this._layerView.visibleTelemetryElements.sensorTrail)}toggleFrameCenterDisplay(){this._layerView?.visibleTelemetryElements&&(this._layerView.visibleTelemetryElements.frameCenter=!this._layerView.visibleTelemetryElements.frameCenter)}toggleFrameOutlineDisplay(){this._layerView?.visibleTelemetryElements&&(this._layerView.visibleTelemetryElements.frameOutline=!this._layerView.visibleTelemetryElements.frameOutline)}changePlaybackSpeed(e){this.layer&&(this.layer.playbackRate=e)}changeGraphicsColor(e){this._layerView&&(this._layerView.symbolColor=e)}_followTelemetry(){this.removeHandles("follow"),this.view&&this.layer&&this.addHandles(r((()=>this.layer?.telemetry),(()=>{const e=[],t="follow-sensor"===this.followingMode||"follow-both"===this.followingMode,r="follow-frame"===this.followingMode||"follow-both"===this.followingMode;t&&this.layer?.telemetry.sensorLocation&&e.push(this.layer.telemetry.sensorLocation),r&&this.layer?.telemetry.frameCenter&&e.push(this.layer.telemetry.frameCenter),e.length&&this.view?.goTo(e).catch((()=>{}))}),l),"follow")}};e([i()],n.prototype,"_layerView",null),e([i({readOnly:!0})],n.prototype,"buffered",null),e([i({readOnly:!0})],n.prototype,"currentTime",null),e([i({readOnly:!0})],n.prototype,"duration",null),e([i({readOnly:!0})],n.prototype,"ended",null),e([i()],n.prototype,"followingMode",void 0),e([i()],n.prototype,"layer",void 0),e([i({readOnly:!0})],n.prototype,"metadata",null),e([i({readOnly:!0})],n.prototype,"playing",null),e([i()],n.prototype,"seekLength",void 0),e([i({readOnly:!0})],n.prototype,"state",null),e([i()],n.prototype,"view",void 0),n=e([s("esri.widgets.VideoPlayer.VideoPlayerViewModel")],n);const y=n;export{y as default};