tav-media
Version:
Cross platform media editing framework
86 lines (85 loc) • 3.41 kB
JavaScript
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 PAGImageLayer_1;
import { PAGModule } from './pag-module';
import { PAGLayer } from './pag-layer';
import { destroyVerify, wasmAwaitRewind } from './utils/decorators';
import { proxyVector } from './utils/type-utils';
let PAGImageLayer = PAGImageLayer_1 = class PAGImageLayer extends PAGLayer {
/**
* Make a empty PAGImageLayer with specified size.
*/
static make(width, height, duration) {
const wasmIns = PAGModule._PAGImageLayer._Make(width, height, duration);
if (!wasmIns)
throw new Error('Make PAGImageLayer fail!');
return new PAGImageLayer_1(wasmIns);
}
/**
* Returns the content duration in microseconds, which indicates the minimal length required for
* replacement.
*/
contentDuration() {
return this.wasmIns._contentDuration();
}
/**
* Returns the time ranges of the source video for replacement.
*/
getVideoRanges() {
const wasmIns = this.wasmIns._getVideoRanges();
if (!wasmIns)
throw new Error('Get video ranges fail!');
return proxyVector(wasmIns, (wasmIns) => wasmIns);
}
/**
* [Deprecated]
* Replace the original image content with the specified PAGImage object.
* Passing in null for the image parameter resets the layer to its default image content.
* The replaceImage() method modifies all associated PAGImageLayers that have the same
* editableIndex to this layer.
*
* @param image The PAGImage object to replace with.
*/
replaceImage(pagImage) {
this.wasmIns._replaceImage(pagImage.wasmIns);
}
/**
* Replace the original image content with the specified PAGImage object.
* Passing in null for the image parameter resets the layer to its default image content.
* The setImage() method only modifies the content of the calling PAGImageLayer.
*
* @param image The PAGImage object to replace with.
*/
setImage(pagImage) {
this.wasmIns._setImage(pagImage.wasmIns);
}
/**
* Converts the time from the PAGImageLayer's timeline to the replacement content's timeline. The
* time is in microseconds.
*/
layerTimeToContent(layerTime) {
return this.wasmIns._layerTimeToContent(layerTime);
}
/**
* Converts the time from the replacement content's timeline to the PAGLayer's timeline. The time
* is in microseconds.
*/
contentTimeToLayer(contentTime) {
return this.wasmIns._contentTimeToLayer(contentTime);
}
/**
* The default image data of this layer, which is webp format.
*/
imageBytes() {
return this.wasmIns._imageBytes();
}
};
PAGImageLayer = PAGImageLayer_1 = __decorate([
destroyVerify,
wasmAwaitRewind
], PAGImageLayer);
export { PAGImageLayer };