Restarting timeline
Dear All,
I need to start from the beginning ( restart ) a timeline under some circumstances. I’m using two different types of timelines, one with relative time intervals and another with absolute ones.
The below works fine. If I press button 1 while timeline has already been running, it will start from the beginning ( switch case 1 ):
TL1 = 4001;
Long timeline_array[ ] = {0, 500, 500, 500, 500};
Button_event[TP,1]
{
Push:
{
if ( timeline_active(TL1) == FALSE )
timeline_create(TL1,timeline_array,length_array(timeline_array),TIMELINE_RELATIVE,TIMELINE_ONCE);
else
timeline_set(TL1,0) ; //start from the beginning
}
timeline_event[TL1]
{
switch ( timeline.sequence )
{
case 1: //do something
case 2: //do something
case 3: //do something
case 4: //do something
case 5: //do something
}
}
The below does not work. If I press button 1 while timeline has already been running, it will keep running without restarting from the beginning. I assumed that timeline_set at 0 will set the repetition value at 0 :
TL2 = 4002;
MAX_AUDIO_ZONES = 10;
Long timeline_array[ ] = { 1000 }; //every 1-second
Button_event[TP,1]
{
Push:
{
if ( timeline_active(TL2) == FALSE )
timeline_create(TL2,timeline_array,length_array(timeline_array),TIMELINE_ABSOLUTE,TIMELINE_REPEAT);
else
timeline_set(TL2,0); //start from the beginning
}
timeline_event[TL2]
{
if ( timeline.repetition < MAX_AUDIO_ZONES)
fnExtron_RequestAudioOutput (type_cast(timeline.repetition+1));
else
timeline_kill(TL2);
}
Am I missing something ?
George
Comments
As far as I know 'timeline_set' does not change the 'timeline.repetition'. You could argue that it should, but also that it shouldn't... It just sets the time for the current repetition back to zero.
What does work for resetting the repetition count is a 'timeline_reload':
In the meantime, I tested the below which is working fine but fewer code lines is always a better solution...
button_event[TP,1]
{
push:
{
if ( timeline_active(TL2) == FALSE )
timeline_create(TL2,timeline_array2,length_array(timeline_array2),TIMELINE_ABSOLUTE,TIMELINE_REPEAT);
else
{
timeline_kill(TL2);
timeline_create(TL2,timeline_array2,length_array(timeline_array2),TIMELINE_ABSOLUTE,TIMELINE_REPEAT);
}
}
}
Another issue I found out is when I'm trying to modify the current timer value of a timeline. I need that to force a timeline to continue executing from another point.
I realized that the "timeline_set" only works for the value 0 ( start from the beginning ). Any other value causes the timeline to start from case 2 !!
Please try the below example:
TL1 = 4001;
Long timeline_array[ ] = {0, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500};
timeline_event[TL1]
{
if ( timeline.sequence == 8)
{
timeline_set(TL1,13);
}
send_string 0,"'TL1 repetition :',itoa(timeline.sequence)";
}
button_event[dvTP,1]
{
push:
{
if ( timeline_active(TL1) == FALSE )
timeline_create(TL1,lTlTL1,length_array(lTlTL1),TIMELINE_RELATIVE,TIMELINE_ONCE);
}
Any ideas ?
Timeline _set references an absolute time so you can set it anywhere between 0 and the last time.
timeline_set(TL, lTime[2]) sets it to the second landmark
timeline_set(TL,lTime[length_array(lTime) - 1] sets it 1 milliseconds before the end
can you please make it more clear ?
suppose you have the below:
long lTime[ ] = { 0,1000,7000,2000,10000,5000 }; //total 25-seconds ( 6 sequences )
timeline_event[TL]
{
switch (timeline.sequence)
{
case 1: send_string 0,"'I am at 1'";
case 2: send_string 0,"'I am at 2'";
case 3: send_string 0,"'I am at 3'";
case 4: send_string 0,"'I am at 4'";
case 5: send_string 0,"'I am at 5'";
case 6: send_string 0,"'I am at 6'";
}
}
When timeline has reached case 2 "I am at 2" and I need to jump at case 5, should I set the time just before that case that is just before the 20th second ( 4th landmark ) ?
If so, which should be the syntax of timeline_set ?
Thanks
for absolute time:
timeline_set(TL, lTime[4] - 10) // 10 milliseconds
for relative time
timeline_set(TL, lTime[1] + lTime{2] + lTime[3] +lTime[4] - 10)
... this is assuming the time are ordered in the array. If they're not your on your own for that math - but it will be the same math.