Tickers present text and graphics information as scrolling lines. You can use simple text, text files, RSS feeds as sources for tickers. Character Generator tickers are available in both MPlatform and MFormats. Ticker creation and content management use the same CG methods; the SDKs differ in how frames reach the CG object.
Default XML description of ticker looks like:
<cg-item group-type='ticker' id='ticker-000'>
<graphics type='rect' color='white(120)/mll(180)'/>
<ticker type='crawl' speed='-2.0' gapless-crawl='no' distance='1.0' line-height='1.0'>
<background type='rect' color='white(120)/mll(180)'/>
<default-text bold='true' size='1.0' style='uppercase'/>
</ticker>
<cg-props pos-x='0' pos-y='413' width='720' height='24' show='yes' move-type='accel-both' alpha='255' bg-color='Black(0)' pixel-ar='0.' play-mode='loop' interlace='auto' scale='fit-ar' align='top-left' pause='no' edges-smooth='0'>
<indent left='0' right='0' top='0' bottom='0' use-for-bg='no'/>
<group-indent left='0' right='0' top='0' bottom='0'/>
</cg-props>
<internal/>
</cg-item>
And ticker looks like:
Ticker properties are nested in the <ticker> node. It contains the ticker parameters and child nodes: <background> describes the background area, and <default-text> defines default formatting for text content. The sibling <cg-props> node describes the CG item's geometry and other base properties.
Ticker is kind of group of items: graphics and text are combined into the ticker. <background> node is duplicated in <graphics> node (see example above) - you can modify background of ticker like common graphics item within <background> node. <default-text> may contain all the attributes that are possible for a text item. Note please that you should set default text properties before adding text content.
You can use an image as a background for the ticker by setting in XML description:
<background path='c:\myTickerBackground.png'/>
Creating a ticker
To add a new ticker to your Character Generator configuration you should create an XML description of your required ticker and use TickerAddNew method.
string tickerItemXML= @"<cg-item>
<ticker type='crawl'/>
<graphics color='ML(180)-White(180)'/>
<default-text bold='true' size='20' />
</cg-item>";
string tickerName = "ticker-item";
double posX = 0.05;
double posY = 0.05;
double sizeX = 0.0;
double sizeY = 0.0;
int isRelative = 1;
int isDisplay = 1;
m_objCharGen.TickerAddNew(tickerItemXML, posX, posY, sizeX, sizeY, isRelative, isDisplay, ref tickerName);
The following table covers the arguments of TickerAddNew. These are method arguments on the CG object, rather than SDK object properties.
| Public argument | Type and units | Direction | Meaning |
|---|---|---|---|
_bsItemTypeOrXMLDesc |
String (BSTR) | Input | Ticker description. Accepts a full <cg-item> containing <ticker>, a standalone <ticker>, an attribute description, or a ticker type such as crawl or roll. |
_dblPosX |
Double; pixels or relative fraction | Input | Horizontal position. The coordinate mode is selected by _bRelativePos. |
_dblPosY |
Double; pixels or relative fraction | Input | Vertical position. The coordinate mode is selected by _bRelativePos. |
_dblSizeX |
Double; pixels or relative fraction | Input | Width. A nonzero argument takes priority over cg-props width. Zero requests XML sizing, followed by automatic sizing if no dimension is supplied. |
_dblSizeY |
Double; pixels or relative fraction | Input | Height. A nonzero argument takes priority over cg-props height. Zero requests XML sizing, followed by automatic sizing if no dimension is supplied. |
_bRelativePos |
BOOL; C# integer flag | Input | Use 0 for pixel position and size arguments, or 1 for fractions of the CG output dimensions, such as 0.5 for half the width or height. |
_bShow |
BOOL; C# integer flag | Input | Initial visibility: 0 creates a hidden ticker; 1 shows it. |
_pbsTickerID |
String (BSTR); C# ref string
|
Input/output | Requested unique item ID and returned ID. An empty input allows CG to generate an ID. Use the returned value when adding content. |
Choosing width and height from XML
For a full <cg-item> description, set the ticker's dimensions in its <cg-props> child and pass zero for the corresponding size arguments. Width and height are resolved independently: you can take both from XML or explicitly override only one.
| XML entry | Type and units | Access | Use |
|---|---|---|---|
<cg-props width='…'/> |
Numeric pixels or a percentage string, such as 80%
|
Configurable in the creation description | Supplies width when _dblSizeX is zero. |
<cg-props height='…'/> |
Numeric pixels or a percentage string, such as 5%
|
Configurable in the creation description | Supplies height when _dblSizeY is zero. |
This table covers the XML dimensions used at ticker creation, rather than all CG base properties. Positive numeric XML dimensions are pixels; use an explicit percent sign for relative XML dimensions. The _bRelativePos flag selects the units of the numeric method arguments and does not turn pixel values in cg-props into relative fractions.
For each zero size argument, CG first reads the corresponding cg-props dimension, then falls back to a width or height attribute on the description's root element. If no size is supplied, automatic sizing remains available and depends on ticker type and output geometry. Position and initial visibility still come from the method arguments; the XML sizing rule does not mean that every property in a full cg-props node is imported by this method.
Legacy width and height attributes directly on <ticker> are also processed during item creation and can override the dimensions selected earlier. For predictable sizing with a full description, keep the dimensions in <cg-props> and avoid conflicting dimensions on <ticker>.
string tickerXml = @"<cg-item group-type='ticker'>
<ticker type='crawl' speed='-2.0'>
<default-text font='Arial' size='20'/>
</ticker>
<cg-props width='640' height='32'/>
</cg-item>";
string tickerNameFromXml = "ticker-from-xml";
m_objCharGen.TickerAddNew(
tickerXml, 20, 400, 0, 0, 0, 1, ref tickerNameFromXml);
m_objCharGen.TickerAddContent(
tickerNameFromXml, "Sample Text", "remove-all");
This example creates a ticker at pixel position (20, 400), with width 640 pixels and height 32 pixels taken from XML. To override only the width, pass a nonzero width and leave height zero:
string tickerNameWithOverride = "ticker-width-override";
m_objCharGen.TickerAddNew(
tickerXml, 20, 400, 800, 0, 0, 1, ref tickerNameWithOverride);
m_objCharGen.TickerAddContent(
tickerNameWithOverride, "Sample Text", "remove-all");
The second ticker uses an explicit width of 800 pixels and the XML height of 32 pixels. Supply the description when creating the ticker; editing that string afterwards does not resize an existing item. Use SetItemSize to resize an existing ticker.
To add content to the ticker you should call TickerAddContent method:
string tickerID = "ticker-item"; string tickerContent = "Sample Text"; string tickerAddType = "remove-all"; m_objCharGen.TickerAddContent(tickerID, tickerContent, tickerAddType);
Using the ticker in each SDK
Create one CG object and configure its ticker with the methods above. Configure default text formatting before adding text content.
MPlatform
Add the CG object to the source's plugin collection. The connected MPlatform pipeline passes frames through the plugin; the application does not need to call ProcessFrame for every frame. For example, with an existing playlist:
var m_objCharGen = new MLCHARGENLib.CoMLCharGen(); m_objPlaylist.PluginsAdd(m_objCharGen, 0); // Create the ticker and add content on m_objCharGen.
Keep the plugin attached while the pipeline uses it. Remove it with m_objPlaylist.PluginsRemove(m_objCharGen) before releasing the CG object.
MFormats
Process frames explicitly in the application's frame loop. After pulling a frame from the reader, pass it to the CG object's IMFProcess.ProcessFrame method and send the returned frame to the preview, writer, or renderer.
// m_objCharGen is the configured CG object.
// pFrame is an input frame already acquired by the surrounding frame loop.
MFORMATSLib.MFFrame processedFrame = null;
try
{
((MFORMATSLib.IMFProcess)m_objCharGen).ProcessFrame(
pFrame, out processedFrame, out int framesRest, "");
if (processedFrame != null)
m_objPreview.ReceiverFramePut(processedFrame, 0, "");
}
finally
{
if (processedFrame != null)
System.Runtime.InteropServices.Marshal.ReleaseComObject(processedFrame);
}
// The surrounding loop must also release its acquired pFrame reference.
Continue processing frames while the ticker is displayed so its animation can advance. Stop calls into CG before releasing the CG object.
Ticker Types
There are several types of ticker items in Character Generator. Each type has its specific behavior, format, and parameters.
| Ticker type | Description | Parameters | Example |
|---|---|---|---|
| crawl | a line of text crawling horizontally |
speed - speed of text flow. Sign of value indicates a duration of content flow. gapless-crawl - indicates whether the crawl is displayed without gaps distance - a distance between rows or ticker content items line-height - relative height of text line |
<ticker type='crawl' speed='-2.0' gapless-crawl='no' distance='1.0' line-height='1.0'> |
| roll | multiline roll of text scrolling vertically |
speed - speed of text flow. Sign of value indicates a duration of content flow. distance - distance between rows or ticker content items line-width - relative width of a text line |
<ticker type='roll' speed='-2.0' distance='0.2' line-width='0.9'> |
| ticker-horz-XX | horizontal appearance of ticker lines. XX means number of lines |
lines - a number of lines start-time - time delay before content starts to flow show-time - time interval for which item is displayed line-width - relative line width line-height - relative line-height distance - distance between rows or ticker content items intro-time - time for item appearance exit-time - time for item hiding group-show - set of effects for item appearance group-hide - set of effects for item hiding line-intro-delay - the delay between lines appearance line-exit-delay - the delay between lines hiding |
<ticker type='ticker-horz-3' lines='3' start-time='0.5' show-time='1.0' line-width='0.9' line-height='1.0' distance='0.2' intro-time='0.4' exit-time='0.4' group-show='right, blur-x' group-hide='left, blur-x'> |
| ticker-vert-XX | vertical appearance of ticker lines. XX means a number of lines. |
lines - a number of lines start-time - time delay before content starts to flow show-time - time interval for which item is displayed line-width - relative line width line-height - relative line-height distance - distance between rows or ticker content items intro-time - time for item appearance exit-time - time for item hiding group-show - set of effects for item appearance group-hide - set of effects for item hiding line-intro-delay - the delay between lines appearance line-exit-delay - the delay between lines hiding |
<ticker type='ticker-vert-3' lines='3' start-time='0.5' show-time='1.0' line-width='0.9' line-height='1.0' distance='0.2' intro-time='0.2' exit-time='0.2' group-show='bottom, blur-y' group-hide='top, blur-y'> |
Content Management
You can use different types of ticker content: you can set text manually, load it from a text file, load it from RSS feed and create your own tickers with images.
Any type of ticker content is loaded with the TickerAddContent method:
string tickerID = "ticker-item"; string tickerContent = "Sample Text"; string tickerAddType = "remove-all"; m_objCharGen.TickerAddContent(tickerID, tickerContent, tickerAddType);
tickerAddType may take the following values:
- "remove-all" - clears ticker content and adds new content to the ticker
- "remove-first" - removes the only 1st item in the ticker and adds new content to the end
- an empty string ("") - adds new content to the end of existed one
Also, you can add "multiline" attribute to tickerAddType value (even to an empty string) to make each line of your ticker content as separated ticker item.
Simple text content
Default text settings for ticker content (font, color etc.) are set in <default-text> ticker node in XML description. You can specify ticker text when you add content. To do it you should use XML description for <text> item:
string tickerID = "ticker-item"; string tickerContent = "<text font='Times New Roman Italic' color='Black'>Modified Sample Text</text>"; string tickerAddType = "remove-all"; m_objCharGen.TickerAddContent(tickerID, tickerContent, tickerAddType);
You can specify several <text> entries in a single content item.
Content from files
To load a file as ticker content you should use a path to the file as ticker content:
string tickerID = "ticker-item"; string tickerContent = @"c:\myTicker.txt"; string tickerAddType = "remove-all"; m_objCharGen.TickerAddContent(tickerID, tickerContent, tickerAddType);
You can format your text in the file by using <text> entries. For example, the content of the file looks like:
Sample Ticker From file Multiline Text test <text color='Red'>Text formatting</text>
and the result looks like:
You can add images as ticker content in the same way:
string tickerID = "ticker-item"; string tickerContent = @"c:\myPhoto.png"; string tickerAddType = ""; m_objCharGen.TickerAddContent(tickerID, tickerContent, tickerAddType);
By default, the images are scaled to fill text line parameters (width or height). To specify properties of any item that is used in ticker you should get the item from the ticker group.
XML structure for the ticker, in this case, looks like:
<cg-item group-type='ticker' id='ticker-000'>
<graphics type='rect' color='white(120)/mll(180)'/>
<ticker type='crawl' speed='-2.0' gapless-crawl='no' distance='1.0' line-height='1.0'>
<background type='rect' color='white(120)/mll(180)'/>
<default-text bold='true' size='1.0' style='uppercase'/>
<content>
<content-item path='C:\TickerText.txt' track-file='yes' modification-time='0x01D0E2777A7592DF'/>
</content>
</ticker>
<cg-props pos-x='0' pos-y='413' width='720' height='24' show='yes' move-type='accel-both' alpha='255' bg-color='Black(0)' pixel-ar='0.' play-mode='loop' interlace='auto' scale='fit-ar' align='top-left' pause='no' edges-smooth='0'>
<indent left='0' right='0' top='0' bottom='0' use-for-bg='no'/>
<group-indent left='0' right='0' top='0' bottom='0'/>
</cg-props>
<internal ignore-ticker='no'/>
</cg-item>
You can specify whether Character Generator updates ticker content from a file when you make changes with it or not. To do it you should specify 'track-file' attribute for <content-item> node. Possible values are 'yes' and 'no'.
In the file that you use as ticker source you can add images with this structure:
[[IMG_1:pathToImage]]Comments
where IMG_1 is an identifier of an image, so check that you use unique IDs (e.g. IMG_1, IMG_2 etc), pathToImage is a path to your file, Comments are used in case of the image doesn't exist.
RSS feeds
You can use RSS feeds as ticker content. RSS is set the same way as text files:
string tickerID = "ticker-item"; string tickerContent = @"http://newsrss.bbc.co.uk/rss/sportonline_world_edition/front_page/rss.xml"; string tickerAddType = ""; m_objCharGen.TickerAddContent(tickerID, tickerContent, tickerAddType);
It takes a time to load RSS content (depends on network connection) so it is recommended to load RSS feeds before to show the ticker.
Result for roll ticker looks like:
After loading an RSS XML configuration looks like:
<cg-item group-type='ticker' id='ticker-000'>
<graphics type='rect' color='white(120)/mll(180)'/>
<ticker type='roll' speed='-2.0' distance='0.2' line-width='0.9'>
<background type='rect' color='white(120)/mll(180)'/>
<rss ttl-update='true' rewind-update='true'>
<rss-header><image width='20%' indent='2,2,6,6' border='2' effects='shadow,3'/><block><title bg-color='white(100)' style='uppercase' color='ml'/><description style='normal' word-break='true'/></block></rss-header>
<rss-item><image width='20%' indent='2,2,6,6' border='2' effects='shadow,3'/><block><title indent='10,2' style='uppercase' color='ml'/><description style='normal' word-break='true'/></block></rss-item>
</rss>
<default-text bold='true' size='1.0'/>
<content>
<content-item path='http://newsrss.bbc.co.uk/rss/sportonline_world_edition/front_page/rss.xml' track-file='yes'/>
</content>
</ticker>
<cg-props pos-x='36' pos-y='49' width='648' height='389' show='yes' move-type='accel-both' alpha='255' bg-color='Black(0)' pixel-ar='0.' play-mode='loop' interlace='auto' scale='fit-ar' align='top-left' pause='no' edges-smooth='0'>
<indent left='0' right='0' top='0' bottom='0' use-for-bg='no'/>
<group-indent left='0' right='0' top='0' bottom='0'/>
</cg-props>
<internal ignore-ticker='no'/>
<rss ttl-end='130853414296398899'/>
</cg-item>
It contains a specific <rss> node that defines the visual appearance of RSS items.
The head node - <rss> - contains following attributes:
- ttl-update - indicates whether the title of the RSS is updated when RSS feed is refreshed. Possible values: 'true', 'false'.
- rewind-update - rewinds ticker on an update of RSS feed. Possible values: 'true', 'false'.
Child nodes define behavior for RSS-entries - headers (<rss-header> node) and items bodies (<rss-item> node). Each of these nodes contains separated nodes for images where you can specify its position (indent, width, height) and effects (effects) and text: <title> describes items' titles appearance and <description> describes items' bodies text formatting.
Still have questions?
Tell us what didn’t work or what you’d like clarified.