Using CG events, you can monitor the CG object itself and its items.
There are 5 events for a CG object.
OnCGEvent
The event is raised on every event for a CG item or a composition.
Parameters:
- bsItemOrCompositionID - ID of an item or a composition that has raised the event.
- bsEventType - name of the event.
- bsEventParam - parameters of the event.
Examples of bsEventType:
- TickerModified - raises when a ticker content has been modified. As parameters, a path to the ticker content is used.
- RSSUpdated - raises when a source of an RSS has been updated.
- FileModified - raises when a source file of an item has been modified. Works only in case "track-file" attribute is enabled for the item. As parameters, it uses a path to the file.
- CompositionsDisplay - raises when a composition has been displayed.
- CompositionsExit - raises when a composition has been hidden.
- ScheduleCompositionsDisplay - raises on displaying of a composition on a timeline.
- ScheduleCompositionsExit - raises on the hiding of a composition on a timeline.
- ScheduleShowItem - raises when an item is shown on a timeline.
- ScheduleHideItem - raises when an item is hidden on a timeline.
- ScheduleUpdateItem - raises when an item has been updated on a timeline.
OnEndOfClip
The event raises when a video clip is over, or an item is out of a frame. Works only in case of "play-mode" attribute is set to "onetime" or "onetime-hide".
It has only bsItemID as a parameter that shows the ID of the item that's over.
OnFlashCallback
Raises when a flash item event (flash callback) is used. Deprecated with latest releases.
OnFrame
Raises on each processed frame. Works only in case "OnFrameEvent.Enabled" property is enabled for the Character Generator.
OnTransitionDone
Raises when an item has been shown or hidden using a transition.
Parameters:
- bsItemID - item ID
- bShow - indicates whether the item is shown (true) or hidden (false).
Code examples of the events
C#
Firstly, attach all the necessary events right after an instance of MLCHARGENLib.CoMLCharGen class is created:
m_objCharGen.OnCGEvent += M_objCharGen_OnCGEvent; m_objCharGen.OnEndOfClip += M_objCharGen_OnEndOfClip; m_objCharGen.OnFlashCallback += M_objCharGen_OnFlashCallback; m_objCharGen.OnFrame += M_objCharGen_OnFrame; m_objCharGen.OnTransitionDone += M_objCharGen_OnTransitionDone;
Then, implement the methods whose signatures you specified in the handlers:
private void M_objCharGen_OnTransitionDone(string bsItemID, bool bShow)
{
throw new NotImplementedException();
}
private void M_objCharGen_OnFrame(double dblTime, int nMediaTime, int nFrameNum)
{
throw new NotImplementedException();
}
private void M_objCharGen_OnFlashCallback(string bsItemID, string bsMethodName, string bsParameters)
{
throw new NotImplementedException();
}
private void M_objCharGen_OnEndOfClip(string bsItemID)
{
throw new NotImplementedException();
}
private void M_objCharGen_OnCGEvent(string bsItemOrCompositionID, string bsEventType, string bsEventParam)
{
throw new NotImplementedException();
}
VB.NET:
Firstly, add handler for all the necessary events right after an instance of MLCHARGENLib.CoMLCharGen class is created:
AddHandler m_objCharGen.OnCGEvent, New IMLCharGenEvents_OnCGEventEventHandler(AddressOf m_objCharGen_OnCGEvent)
AddHandler m_objCharGen.OnEndOfClip, New IMLCharGenEvents_OnEndOfClipEventHandler(AddressOf m_objCharGen_OnEndOfClip)
AddHandler m_objCharGen.OnFlashCallback, New IMLCharGenEvents_OnFlashCallbackEventHandler(AddressOf m_objCharGen_OnFlashCallback)
AddHandler m_objCharGen.OnFrame, New IMLCharGenEvents_OnFrameEventHandler(AddressOf m_objCharGen_OnFrame)
AddHandler m_objCharGen.OnTransitionDone, New IMLCharGenEvents_OnTransitionDoneEventHandler(AddressOf m_objCharGen_OnTransitionDone)
Then, implement the methods whose signatures you specified in the handlers:
// Code withing program class:
Private Sub m_objCharGen_OnCGEvent(bsItemOrCompositionID As String, bsEventType As String, bsEventParam As Object)
Throw New NotImplementedException()
End Sub
Private Sub m_objCharGen_OnEndOfClip(bsItemID As String)
Throw New NotImplementedException()
End Sub
Private Sub m_objCharGen_OnFlashCallback(bsItemID As String, bsMethodName As String, bsParameters As String)
Throw New NotImplementedException()
End Sub
Private Sub m_objCharGen_OnFrame(dblTime As Double, nMediaTime As Integer, nFrameNum As Integer)
Throw New NotImplementedException()
End Sub
Private Sub m_objCharGen_OnTransitionDone(bsItemID As String, bShow As Boolean)
Throw New NotImplementedException()
End Sub
Delphi:
// 1. Define a custom class TCGEvents (Right after "uses" field of your app .pas file):
Type TCGEvents = class (TInterfacedObject, IMLCharGenCallback)
function OnFrame(llCallbackCookie: Int64; dblTime: Double; nMediaTime: Int32; nFrameNum: Int32): HResult; stdcall;
function OnEndOfClip(llCallbackCookie: Int64; const bsItemID: WideString): HResult; stdcall;
function OnTransitionDone(llCallbackCookie: Int64; const bsItemID: WideString; bShow: WordBool): HResult; stdcall;
function OnFlashCallback(llCallbackCookie: Int64; const bsItemID: WideString; const bsMethodName: WideString; const bsParameters: WideString): HResult; stdcall;
function OnCGEvent(llCallbackCookie: Int64; const bsItemOrCompositionID: WideString; const bsEventType: WideString; const bsEventParam: WideString): HResult; stdcall;
end;
// 2. Declare variables in the global "var" section of your app:
private
m_objCharGen: CoMLCharGen;
m_objCGEvents: TCGEvents;
// 3. Create an instance of TCGEvents class within .FormCreate(Sender: TObject); procedure:
m_objCGEvents := TCGEvents.Create();
// 4. Start listening these events with ObjectCallbackSet method (m_objCharGen should be created):
m_objCharGen.AddCallback(m_objCGEvents, 0);
Then, implement the methods whose signatures you specified in the very beginning:
// 5. Create implementation of the CG Events and the functions within "implementation" section:
function TCGEvents.OnCGEvent(llCallbackCookie: Int64; const bsItemOrCompositionID: WideString; const bsEventType: WideString; const bsEventParam: WideString): HResult; stdcall;
begin
CG_Int1 := CG_Int1 + 1;
Form2.CG_Label_1.Caption := 'OnCGEvent #' + IntToStr(CG_Int1);
end;
function TCGEvents.OnFrame(llCallbackCookie: Int64; dblTime: Double; nMediaTime: Int32; nFrameNum: Int32): HResult; stdcall;
begin
CG_Int2 := CG_Int2 + 1;
Form2.CG_Label_2.Caption := 'OnFrame #' + IntToStr(CG_Int2);
end;
function TCGEvents.OnEndOfClip(llCallbackCookie: Int64; const bsItemID: WideString): HResult; stdcall;
begin
CG_Int3 := CG_Int3 + 1;
Form2.CG_Label_3.Caption := 'OnEndOfClip #' + IntToStr(CG_Int3);
end;
function TCGEvents.OnTransitionDone(llCallbackCookie: Int64; const bsItemID: WideString; bShow: WordBool): HResult; stdcall;
begin
CG_Int4 := CG_Int4 + 1;
Form2.CG_Label_4.Caption := 'OnTransitionDone #' + IntToStr(CG_Int4);
end;
function TCGEvents.OnFlashCallback(llCallbackCookie: Int64; const bsItemID: WideString; const bsMethodName: WideString; const bsParameters: WideString): HResult; stdcall;
begin
CG_Int5 := CG_Int5 + 1;
Form2.CG_Label_5.Caption := 'OnFlashCallback #' + IntToStr(CG_Int5);
end;