After Effects Scripts: How to Add a Song with Start Time Displayed in a Song

I have three compositions ( compFinal, compSlide1and compSlide2).

I used a script to add compSlide1and compSlide2in the composition compFinal.

I use the following code to add songs:

compFinal.layers.add(compSlide1); 
compFinal.layers.add(compSlide2); 

But when you insert them into compFinalboth compositions compSlide1, compSlide2they will have the same start time "0".

When adding a song, compSlide2I want me to be able to set the start time displayed for composition 2 to be equal to the endcompSlide1

enter image description here

+4
source share
1 answer

, startTime outPoint, , .

, , ( ):

// initial time (in seconds)
var time = 0;

// loop through all layers in comp
for(var i = 1; i <= finalComp.layers.length; i++) {

    // set layer startTime based on current time value
    finalComp.layers[i].startTime = time;

    // update time to hold outPoint time of this layer
    // which will next layer start time
    time = finalComp.layers[i].outPoint;
}

, out-point:

finalComp.layers[2].startTime = finalComp.layers[1].outPoint;
+1

Source: https://habr.com/ru/post/1686404/


All Articles