FORUMS: list search recent posts

# Play and Pause on markers

FAQ   •   VIEW ALL
 Play and Pause on markers on Oct 21, 2015 at 5:40:43 pm

I know this should be easy, but I'm trying to write a time remap expression freeze and play based on clip markers. I am surprised i couldn't find this already made. I will post it if I figure it out.

 Re: Play and Pause on markerson Oct 21, 2015 at 6:51:51 pm

I'm not sure what you have in mind exactly, but since expressions have no memory, your expression will need to calculate how much play time has occurred in the past by examining each marker previous to the current time.

Dan

 Re: Play and Pause on markerson Oct 21, 2015 at 7:42:23 pm

I understood this, and that is the part I'm trying to figure out. I wrote this after sending the post, but I still need to write something for calculating totaltime of the odd or even marker differences.

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

 Re: Play and Pause on markerson Oct 21, 2015 at 7:47:52 pm

Are the odd numbers play or pause?

Dan

 Re: Play and Pause on markerson Oct 21, 2015 at 7:50:55 pm

Currently The odd numbers are pause and I'm starting clip off frozen with marker off top.

 Re: Play and Pause on markerson Oct 21, 2015 at 7:49:41 pm

My last post didn't paste correctly. Something weird between Mac and PC text.

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

 Re: Play and Pause on markerson Oct 21, 2015 at 7:55:42 pm

If you're going to post code, don't preview your post, or all the < characters will get converted to html codes when you finally post it.

Dan

 Re: Play and Pause on markerson Oct 21, 2015 at 7:58:18 pm

Thanks. Was going crazy. < > test lol

 Re: Play and Pause on markerson Oct 21, 2015 at 8:43:20 pm

I think it will be something like this:

``` m = thisLayer.marker; if (m.numKeys > 0){ i = 1; segStart = 0; accum = 0; for (i = 1; i <= m.numKeys; i++){ if (m.key(i).time < time){ if (i%2){ accum += m.key(i).time - segStart; segStart = null; }else{ segStart = m.key(i).time; } }else{ break; } } if (segStart != null){ accum += time - segStart; } accum; }else time ```

Dan

 Re: Play and Pause on markerson Oct 21, 2015 at 8:50:22 pm

Looks good to me. Thanks, your biggest fan (probably not, since you are a rock star).

 Re: Play and Pause on markerson Oct 21, 2015 at 10:47:41 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}```

 Re: Play and Pause on markerson Oct 21, 2015 at 11:14:03 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