I realise this post was from some time ago, but I have a similar question, but simpler:
All I need to do, is get the index of a marker AT THE CURRENT TIME, not that fairly annoying/useless “nearestKey” thing, which changes whenever the current time is kinda near the marker, not ON the marker. I’m guessing the (somewhat convoluted) way of going about it would be:
1. Get the TIME of the nearestKey
2. When the current time >= the nearestKey’s time, use that nearestKey’s index
…or something. Basically, all I want to do is be able to control the appearance, word-by-word, of a text layer, and be able to trigger that by hammering in a load of markers (easily done with a text animator/opacity/based on words). But getting the “nearestKey” to be “exactKey” is a right pain!
Any ideas/help would be greatly appreciated, please!
~ Paul
UPDATE: From a bit more hunting around here, I found something by @Meng Zhiqun, and pinched a bit of expression from there. It generates an error if the time is before the first marker, but I can live with that:
n = 0;
if (marker.numKeys > 0) {
n = marker.nearestKey(time).index;
if (marker.key(n).time > time) {
n--;
}
marker.key(n).index
}
else {0}
All seems quite convoluted to just get the index of the current marker!