-
Notifications
You must be signed in to change notification settings - Fork 7
Using ICasparCGMedia objects
All media files which are playable by CasparCG are mapped into ICasparCGMedia objects.
This are namely:
- CasparCGAudio
- CasparCGColor
- CasparCGMovie
- CasparCGStill
- CasparCGTemplate
They are holding all the data necessary to work with them.
All are implementing the ICasparCGMedia interface.
ICasparCGConnection:
Properties:
Name
Path
Fullname
Infos
Base64Thumbnail
MediaType
Methods:
addInfo(key, value)
setInfo(key, value)
parseXml(xml)
fillMediaInfo(connection, [channel])
fillMediaInfo(connection, [channel])
Functions:
clone() -> ICasparCGMedia
containsInfo(key) -> Boolean
getInfo(key) -> String
toString() -> String
toXml() -> XmlDocument
toXmlString() -> String
To create a new instance of any ICasparCGMedia, all you need is the fully qualified name of the media. This is even enough to play all media objects and use them with CasparCGCommands. But to get all out of them, we need to gather more information. Luckily, CasparCG is providing them.
To fill these informations, there are two ways.
- Provide a XML definition of the media object and call the parseXml(xml) method. This can be queried with the InfoCommand or may be saved to a file.
- Let the object get the data itself by calling the fillMediaInfo(connection) method. You need to provide a working connection to a CasparCG Server containing this media in its media/template directory.
After calling one of them, the media object knows everything that is important. What exactly this is depends on the media type. All in common is, that you can find this metadata as a key-value store inside the Infos property. You may use the provided getter/setter functions to access them.
You can use this key-value store for your own storage too. If you would like to add infos to media object, just add a new Info to your object using the add(key,value) method.
There are two media types which differs a bit.
The CasparCGColor is not a real media as it only defines a color that has no metadata and is not stored on the CasparCG Server. Just define the color via the Name.
The CasparCGTemplate provides much more data then the other media types.
In addition to the metadata, it can hold information of the template structure and the data the template shows.
Because of this, the CasparCGTemplate provides a wider set of functions:
CasparCGTemplate
Functions:
getData() -> CasparCGTemplateData
getDataString() -> String
hasData() -> Boolean
CasparCGTemplateData
Methods:
addInstance(instance)
Functions:
containsInstance(instanceName) -> Boolean
getInstance(instanceName) -> CasparCGTemplateInstance
getInstances() -> IEnumerable(Of CasparCGTemplateInstance)
hasData() -> Boolean
toDataString() -> String
toDataXml() -> XmlDocument
CasparCGTemplateInstance
Functions:
getName() -> String
getComponent() -> CasparCGTemplateComponent
getProperties() -> IEnumerable(Of CasparCGTemplateProperty)
getProperty(propertyName) -> CasparCGTemplateProperty
hasData() -> Boolean
setValue(propertyName, value) -> Boolean
toDataXml() -> XmlDocument
toXml() -> XmlDocument
CasparCGTemplateProperty
Properties:
Name
Type
Info
Value
Functions:
isSet() -> Boolean
toDataXml() -> XmlDocument
toXml() -> XmlDocument
To make things short, all you need to know is, that the CasparCGTemplateData contains one CasparCGTemplateInstance for every accessible TextField in your template.
The typical CasparTextField used in flashtemplates provides only one property called "text".
So, you would access the data of TextField f0 like this:
template.getData().getInstance("f0").setValue("text","New value")
value = template.getData.getInstance("f0").getProperty("text").Value