You can schedule Character Generator behavior by using IMLCharGenSchedule interface and its methods. To schedule your configuration you should create a timeline, manage its content and start it.
Create a timeline
To create a new scheduling timeline you should call ScheduleAdd method. This method contains the following parameters:
- _bsTimelineID - identifier of scheduling timeline. If there is no existed timeline with this ID a new one is created.
- _bsItemOrCompositionID - identifier of item or composition that you plan to use in timeline
- _bsParamStringOrXMLFullDesc - string with parameters or XML description that you plan to change while timeline
- _pTimes - item schedule time.
Scheduling time is specified in CG_SCHEDULE_TIMES structure, that has fields:
- dblExitTime - time to reset changes when timeline is stopped
- dblIntroTime - time to implement changes smooth while timeline is running
- dblScheduledTime - time moment from timeline start to begin to implement changes
- dblShowTime - minimal time interval for which item is in static state
- nShowHide - indicates whether item is showed after timeline is over
For example, to create a new timeline in source code you should call:
CG_SCHEDULE_TIMES myTime = new CG_SCHEDULE_TIMES();
myTime.dblScheduledTime = 5.0;
myTime.dblShowTime = 10.0;
myTime.dblExitTime = 5.0;
myTime.dblIntroTime = 5.0;
myTime.nShowHide = 1;
string newTimeLineID = "newTimeline";
string targetItemID = "text-000";
string targetItemProps = "cg-props::height='200'";
(myCharGen as IMLCharGenSchedule).ScheduleAdd(newTimeLineID, targetItemID, targetItemProps, ref myTime);
In this example, when the timeline is started text item height will be settings to 200 for 5 seconds after the 5-second interval.
Manage timeline content
To add a new entry into timeline you should use ScheduleAdd method with an identifier of the existed timeline. You can add as many entries as you wish for any item - you can use several scheduling actions for the same item at once.
To get a number of scheduled actions you should use ScheduleGetCount method:
int scheduledCount;
string timelineID = "newTimeline";
(m_objCharGen as IMLCharGenSchedule).ScheduleGetCount(timelineID, out scheduledCount);
To get information about the action you should use ScheduleGet method - this method returns you all the setting you set with the ScheduleAdd method by the index of required entry:
int targetEntryIndex = 1;
string timelineID = "newTimeline";
CG_SCHEDULE_TIMES resultTime;
string resultID;
string resultProps;
(myCharGen as IMLCharGenSchedule).ScheduleGet(timelineID, targetEntryIndex, out resultID, out resultProps, out resultTime);
You can remove an unnecessary entry by its index from the timeline with ScheduleRemove method:
int targetEntryIndex = 1;
string timelineID = "newTimeline";
(myCharGen as IMLCharGenSchedule).ScheduleRemove(timelineID, targetEntryIndex);
Timeline playback
You can manage timeline running behavior: start it, pause, resume and stop.
To start a timeline you should call ScheduleTimelineStart method. This method contains the following parameters:
- _bsTimelineID - identifier of scheduling timeline that you plan to start
- _dblStartTime - time interval in seconds after which the timeline is started. To start it immediately set it to 0.
- _dblCycleTime - time interval to repeat the timeline. To disable repeat set it to 0.
- _bStopAllOthers - indicates whether all other timelines are stopped when this timeline is running
For example, usage of this method looks like:
string targetTimeline = "newTimeline";
double startTime = 0.0;
double cycleTime = 0.0;
int stopOthers = 0;
(myCharGen as IMLCharGenSchedule).ScheduleTimelineStart(targetTimeline, startTime, cycleTime, stopOthers);
To pause a timeline you should call ScheduleTimelinePause method:
string targetTimeline = "newTimeline";
(myCharGen as IMLCharGenSchedule).ScheduleTimelinePause(targetTimeline);
To resume timeline playback you should call ScheduleTimelineContinue method. With this method you can resume timeline from required time by setting seek time position:
string targetTimeline = "newTimeline";
double seekTime = 10.0;
(myCharGen as IMLCharGenSchedule).ScheduleTimelineContinue(targetTimeline, seekTime);
And to stop timeline there is ScheduleTimelineStop method:
string targetTimeline = "newTimeline";
(myCharGen as IMLCharGenSchedule).ScheduleTimelineStop(targetTimeline);
Multiple timelines usage
If you use several timelines you can get their count with the ScheduleTimelineGetCount method:
int timelinesCount;
(myCharGen as IMLCharGenSchedule).ScheduleTimelineGetCount(out timelinesCount);
To get the identifier of required timeline you should use ScheduleTimelineGetID method - it returns you an identifier by timeline index:
int timelineIndex = 1;
string timelineID;
(myCharGen as IMLCharGenSchedule).ScheduleTimelineGetID(timelineIndex, out timelineID);
By the identifier, you can get all the entries of the timeline. You can get timeline's time parameters and its state with ScheduleTimelineGetTimes method:
string targetTimeline = "newTimeline";
double startTime;
double cycleTime;
eCG_TimelineState timelineState;
(myCharGen as IMLCharGenSchedule).ScheduleTimelineGetTimes(targetTimeline, out startTime, out cycleTime, out timelineState);
Possible states of timeline are listed in the eCG_TimelineState enumeration: paused, running and stopped.