Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

programatically define start of clip

New Here ,
May 28, 2023 May 28, 2023

Hi.

I have a very simple problem for which I cannot find a solution:
How do I start a clip at a time that is defined by an expression, marker, control or script?
Ideally, I would like to somehow connect a marker to a clip so that the clip in the timeline moves with the marker.
One application would be to play a sound ("click") at a time defined by a marker (set to the point at which the finger hits the button).
My ideas: put a freeze frame in front of the clip, whose length can then be changed via a control variable/expression/script.

Or stretch the first frame of the clip to the length of time corresponding to the current time point.

The dream would be to have a method like "PlaySoundAtTime(sound, time)" or "StartClipAtTime(Layer, time)".

Or is there a general rule, why this can't be done?

Many thanks in advance

 

TOPICS
Audio , Expressions , Scripting
298
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 28, 2023 May 28, 2023

I think the closest you could come would be to enable time remapping for your clip layer, drag the right edge of the layer to extend the duration to the length of the comp, add a layer marker, and add this time remapping expression:

m = marker;
t = 0;
if (m.numKeys > 0){
  t = time - m.key(1).time;
}
t  > 0 ? 100 : 0

Then the clip will start playing at the marker. If you want it to be invisible until it starts playing, you could also add this opacity expression:

m = marker;
t = 0;
if (m.numKeys > 0){
  t = time - m.key(1).time;
}
t  > 0 ? 100 : 0

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 28, 2023 May 28, 2023

It works!

This solution has something ingenious in its simplicity!

The key point is to extend the duration. I did it by wrapping the clip in a pre-comp matching the length.

Thank your very much!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 28, 2023 May 28, 2023
LATEST

Sorry, I pasted in the same expression twice. The first one (for time remapping) should have been like this:

m = marker;
t = 0;
if (m.numKeys > 0){
  t = Math.max(time - m.key(1).time, 0);
}
t
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines