@@ -3,6 +3,9 @@ import {Transformation} from "../../transformation/Transformation.js";
33import { VideoSource } from "../../qualifiers/source/sourceTypes/VideoSource.js" ;
44import { ImageSource } from "../../qualifiers/source/sourceTypes/ImageSource.js" ;
55import { FetchSource } from "../../qualifiers/source/sourceTypes/FetchSource.js" ;
6+ import { IActionModel } from "../../internal/models/IActionModel.js" ;
7+ import { IConcatenateActionModel } from "../../internal/models/IConcatenateActionModel.js" ;
8+ import { ITransformationFromJson } from "../../internal/models/IHasFromJson.js" ;
69
710/**
811 * @description Class for Concatenating another video.
@@ -17,6 +20,7 @@ class ConcatenateAction extends Action {
1720 private _prepend : boolean ;
1821 private _duration : number ;
1922 private _transition : VideoSource ;
23+ protected _actionModel : IConcatenateActionModel ;
2024
2125 /**
2226 *
@@ -25,6 +29,11 @@ class ConcatenateAction extends Action {
2529 */
2630 constructor ( source : VideoSource | ImageSource | FetchSource ) {
2731 super ( ) ;
32+ this . _actionModel = {
33+ actionType : 'concatenate' ,
34+ source : { sourceType : 'video' }
35+ } ;
36+
2837 this . concatSource = source ;
2938 }
3039
@@ -124,6 +133,28 @@ class ConcatenateAction extends Action {
124133 close
125134 ] . filter ( ( a ) => a ) . join ( '/' ) ;
126135 }
136+
137+ static fromJson ( actionModel : IActionModel , transformationFromJson : ITransformationFromJson ) : ConcatenateAction {
138+ const { source, transition, prepend, duration} = ( actionModel as IConcatenateActionModel ) ;
139+
140+ // We are using this() to allow inheriting classes to use super.fromJson.apply(this, [actionModel])
141+ // This allows the inheriting classes to determine the class to be created
142+ // @ts -ignore
143+ const result = new this ( VideoSource . fromJson ( source , transformationFromJson ) ) ;
144+ if ( transition ) {
145+ result . transition ( VideoSource . fromJson ( transition , transformationFromJson ) ) ;
146+ }
147+
148+ if ( prepend ) {
149+ result . prepend ( ) ;
150+ }
151+
152+ if ( duration ) {
153+ result . duration ( duration ) ;
154+ }
155+
156+ return result ;
157+ }
127158}
128159
129160export default ConcatenateAction ;
0 commit comments