MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / _addVideoLayer

Method _addVideoLayer

src/mapboxgl/overlay/VideoLayer.js:252–358  ·  view source on GitHub ↗
(map)

Source from the content-addressed store, hash-verified

250 }
251
252 _addVideoLayer(map) {
253 let url = this.videoDomId || this.url;
254 const extent = this.extent || this.timeParams[0].extent;
255 const poly = polygon([
256 [...extent, extent[0]]
257 ]);
258 let result = bbox(poly);
259 let that = this;
260 let srcPixelCoords = [0, 0, that.videoWidth, 0, that.videoWidth, that.videoHeight, 0, that.videoHeight];
261 if (this.clipRegion.length) {
262 srcPixelCoords = [];
263 this.clipRegion.forEach((coord) => {
264 srcPixelCoords.push(coord[0]);
265 srcPixelCoords.push(coord[1]);
266 });
267 }
268 let srcTri = this.cv.matFromArray(4, 1, this.cv.CV_32FC2,
269 srcPixelCoords
270 );
271 that.dsize = that.timeParams[that.beginIndex].dsize;
272 let dstTri = that.timeParams[that.beginIndex].dstTri;
273 let canvas = document.createElement('canvas');
274 let { clipMat, dst1 } = this._updateMask(canvas, that.timeParams[that.beginIndex].realHeight, that.timeParams[that.beginIndex].ratio);
275 let count = 0;
276 const videoEle = this.video.tech().el();
277 let current = 0;
278 if (this.videoParameters.length > 1 && videoEle && videoEle.requestVideoFrameCallback) {
279 const updateCanvas = (now, metadata) => {
280 current = metadata.mediaTime;
281 videoEle.requestVideoFrameCallback(updateCanvas);
282 };
283
284 videoEle.requestVideoFrameCallback(updateCanvas);
285 }
286 map.addSource(this.layerId, {
287 type: 'video',
288 urls: [url],
289 drawImageCallback(frame) {
290 if (that.videoParameters.length > 1) {
291 let time = current || that.video.currentTime();
292 let res = that.finder.findNearest(time);
293 if (res) {
294 count = res.value;
295 }
296
297 if (count) {
298 let curData = that.timeParams[count];
299 count = 0;
300 if (curData) {
301 that.dsize = curData.dsize;
302 dstTri = curData.dstTri;
303 result = curData.result;
304 setTimeout(() => {
305 that.map.getSource(that.layerId).setCoordinates([
306 [result[0], result[3]],
307 [result[2], result[3]],
308 [result[2], result[1]],
309 [result[0], result[1]]

Callers 1

onAddMethod · 0.95

Calls 9

_updateMaskMethod · 0.95
polygonFunction · 0.85
forEachMethod · 0.80
pushMethod · 0.80
createElementMethod · 0.80
addSourceMethod · 0.80
playMethod · 0.80
addLayerMethod · 0.45
getSourceMethod · 0.45

Tested by

no test coverage detected