# Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Play and Pause on markers

• # Play and Pause on markers

4 Members · 19 Posts
• ### Chris Scalzo

October 21, 2015 at 10:47 pm

One more thing I’m trying to figure out with another expression I’m using with the previous. I wrote the following expression to toggle an Effect Opacity on and off with keyframes. I can’t figure out how to use easeOut to ramp the transition from 0 to 100 and back to 0 (on following keyframe).

```try{ m = thisLayer.marker; i = m.nearestKey(time).index; if (m.nearestKey(time).time > time){ i--;} if (i &lt; 1) { i = 1}; i%2*100 }catch(err){1}```

• ### Dan Ebberts

October 21, 2015 at 11:14 pm

This might work:

``` m = thisLayer.marker; easeTime = .25; if (m.numKeys > 0){ i = m.nearestKey(time).index; if (m.nearestKey(time).time > time) i--; if (i > 0){ t = time - m.key(i).time; if (i%2){ ease(t,0,easeTime,100,0); }else{ ease(t,0,easeTime,0,100); } }else{ 100; } }else{ 100; } ```

Dan

• ### Chris Scalzo

October 22, 2015 at 12:00 am

Worked perfectly. Thanks again.

• ### Jan Hofmeister

April 3, 2019 at 8:55 pm

Bringing this oooold thread back up, I was wondering how Dan’s expression up there needs to be changed to not play and stop at each marker, but always stop at each marker and only play for the duration of a marker (you know, when you split and drag it apart with ALT and click).

So basically the time between markers is the hold time, and the duration of each marker is play time. That way it’s a bit more practical for time-remapping purposes, because moving a marker will always move its duration along with it.

• ### Dan Ebberts

April 3, 2019 at 11:44 pm

Something like this maybe:

``` m = thisLayer.marker; accum = 0; if (m.numKeys > 0){ n = m.nearestKey(time).index; if (m.nearestKey(time).time > time) n--; if (n > 0){ for (i = 1; i < n; i++){ accum += m.key(i).duration; } accum += Math.min(time-m.key(n).time,m.key(n).duration); } } accum ```

Dan

• ### Jan Hofmeister

April 4, 2019 at 12:44 am

That’s exactly what I had in mind, thanks so much!

• ### Paul Roper

April 15, 2021 at 9:25 am

Continuing this conversation (from 6 years ago!), I’m looking for a similar way to start playing a layer when it reaches a marker. Here’s my situation:
I have a comp about 2 mins. long. At about 30 intervals (not regular) along the timeline, I want a short (finger click) sound to play. I could just put 30 layers of the sound in the comp and drag them to the appropriate time – but that just seems messy! So I was wondering if there’s a neater, marker-driven approach. I was thinking something like this:
1. Null layer with markers where I want the clicks.
2. AIFF sound layer, with an expression on it to set its time remapping to 0 each time a marker on the Null layer is encountered, so it plays from the start.
Might that work?

Thanks in advance for any help!!

• ### Dan Ebberts

April 15, 2021 at 12:52 pm

Give this time remapping expression a try:

`m = thisComp.layer("Null 1").marker;t = 0;if (m.numKeys > 0){  n = m.nearestKey(time).index;  if (time < m.key(n).time) n--;  t = (n > 0) ? time - m.key(n).time : 0;}t`
• ### Paul Roper

April 15, 2021 at 1:02 pm

As ever, Dan, you are an absolute hero of After Effects! The world of motion graphics people collectively bows down before your expressioneering greatness!

Viewing 11 - 19 of 19 posts