File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -494,6 +494,42 @@ export class Track extends Properties<
494494 return await Promise . all ( clipSlots . filter ( ( cs ) => cs . hasClip ) . map ( async ( cs ) => await cs . clip ( ) ) ) ;
495495 }
496496
497+ /**
498+ * Get a specific clip based on Scene number
499+ *
500+ * @memberof Track
501+ * @return {(Promise<(Clip | null)>) }
502+ */
503+ async getClip ( scene : number ) : Promise < Clip | null > {
504+ const clipSlots = await this . children ( 'clip_slots' ) ;
505+
506+ if ( scene < 1 || scene > clipSlots . length ) return Promise . reject ( null ) ;
507+
508+ const clipSlot = clipSlots [ scene - 1 ] ;
509+
510+ return await clipSlot . clip ( ) ;
511+ }
512+
513+ /**
514+ * Get a specific clip based on Scene number and creates one if there's none
515+ *
516+ * @memberof Track
517+ * @param {number } scene
518+ * @param {number } [length=4]
519+ * @return {(Promise<Clip>) }
520+ */
521+ async getOrCreateClip ( scene : number , length : number = 4 ) : Promise < Clip > {
522+ const clipSlots = await this . children ( 'clip_slots' ) ;
523+
524+ if ( scene < 1 || scene > clipSlots . length ) return Promise . reject ( null ) ;
525+
526+ const clipSlot = clipSlots [ scene - 1 ] ;
527+
528+ if ( ! clipSlot . hasClip ) return await clipSlot . createClip ( length ) ;
529+
530+ return ( await clipSlot . clip ( ) ) as Clip ;
531+ }
532+
497533 /**
498534 * Is the track a group track
499535 *
You can’t perform that action at this time.
0 commit comments