UNPKG

tav-media

Version:

Cross platform media editing framework

178 lines (177 loc) 6.34 kB
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var PAGComposition_1; import { PAGModule } from './pag-module'; import { PAGLayer } from './pag-layer'; import { destroyVerify, wasmAwaitRewind } from './utils/decorators'; import { layer2typeLayer, proxyVector } from './utils/type-utils'; let PAGComposition = PAGComposition_1 = class PAGComposition extends PAGLayer { /** * Make a empty PAGComposition with specified size. */ static make(width, height) { const wasmIns = PAGModule._PAGComposition._Make(width, height); if (!wasmIns) throw new Error('Make PAGComposition fail!'); return new PAGComposition_1(wasmIns); } /** * Returns the width of the Composition. */ width() { return this.wasmIns._width(); } /** * Returns the height of the Composition. */ height() { return this.wasmIns._height(); } /** * Set the width and height of the Composition. */ setContentSize(width, height) { this.wasmIns._setContentSize(width, height); } /** * Returns the number of child layers of this composition. */ numChildren() { return this.wasmIns._numChildren(); } /** * Returns the child layer that exists at the specified index. * @param index The index position of the child layer. * @returns The child layer at the specified index position. */ getLayerAt(index) { const wasmIns = this.wasmIns._getLayerAt(index); if (!wasmIns) throw new Error(`Get layer at ${index} fail!`); return layer2typeLayer(wasmIns); } /** * Returns the index position of a child layer. * @param pagLayer The layer instance to identify. * @returns The index position of the child layer to identify. */ getLayerIndex(pagLayer) { return this.wasmIns._getLayerIndex(pagLayer.wasmIns); } /** * Changes the position of an existing child layer in the composition. This affects the layering * of child layers. * @param pagLayer The child layer for which you want to change the index number. * @param index The resulting index number for the child layer. */ setLayerIndex(pagLayer, index) { return this.wasmIns._setLayerIndex(pagLayer.wasmIns, index); } /** * Add a PAGLayer to current PAGComposition at the top. If you add a layer that already has a * different PAGComposition object as a parent, the layer is removed from the other PAGComposition * object. */ addLayer(pagLayer) { return this.wasmIns._addLayer(pagLayer.wasmIns); } /** * Add a PAGLayer to current PAGComposition at the top. If you add a layer that already has a * different PAGComposition object as a parent, the layer is removed from the other PAGComposition * object. */ addLayerAt(pagLayer, index) { return this.wasmIns._addLayerAt(pagLayer.wasmIns, index); } /** * Check whether current PAGComposition contains the specified pagLayer. */ contains(pagLayer) { return this.wasmIns._contains(pagLayer.wasmIns); } /** * Remove the specified PAGLayer from current PAGComposition. */ removeLayer(pagLayer) { const wasmIns = this.wasmIns._removeLayer(pagLayer.wasmIns); if (!wasmIns) throw new Error('Remove layer fail!'); return layer2typeLayer(wasmIns); } /** * Remove the specified PAGLayer from current PAGComposition. */ removeLayerAt(index) { const wasmIns = this.wasmIns._removeLayerAt(index); if (!wasmIns) throw new Error(`Remove layer at ${index} fail!`); return layer2typeLayer(wasmIns); } /** * Remove all PAGLayers from current PAGComposition. */ removeAllLayers() { this.wasmIns._removeAllLayers(); } /** * Swap the layers at the specified index. */ swapLayer(pagLayer1, pagLayer2) { this.wasmIns._swapLayer(pagLayer1.wasmIns, pagLayer2.wasmIns); } /** * Swap the layers at the specified index. */ swapLayerAt(index1, index2) { this.wasmIns._swapLayerAt(index1, index2); } /** * The audio data of this composition, which is an AAC audio in an MPEG-4 container. */ audioBytes() { return this.wasmIns._audioBytes(); } /** * Returns the audio markers of this composition. */ audioMarkers() { const wasmIns = this.wasmIns._audioMarkers(); if (!wasmIns) throw new Error(`Get audioMarkers fail!`); return proxyVector(wasmIns, (wasmIns) => wasmIns); } /** * Indicates when the first frame of the audio plays in the composition's timeline. */ audioStartTime() { return this.wasmIns._audioStartTime(); } /** * Returns an array of layers that match the specified layer name. */ getLayersByName(layerName) { const wasmIns = this.wasmIns._getLayersByName(layerName); if (!wasmIns) throw new Error(`Get layers by ${layerName} fail!`); return proxyVector(wasmIns, layer2typeLayer); } /** * Returns an array of layers that lie under the specified point. The point is in pixels and from * this PAGComposition's local coordinates. */ getLayersUnderPoint(localX, localY) { const wasmIns = this.wasmIns._getLayersUnderPoint(localX, localY); if (!wasmIns) throw new Error(`Get layers under point ${localX},${localY} fail!`); return proxyVector(wasmIns, layer2typeLayer); } }; PAGComposition = PAGComposition_1 = __decorate([ destroyVerify, wasmAwaitRewind ], PAGComposition); export { PAGComposition };