C# Script Samples
Go to CS-Script - The C# Script Engine website.
CS-Script (pronounced C sharp script) is a CLR (Common Language Runtime) based scripting system which uses ECMA-compliant C# as a programming language. It combines the power and richness of C# with the flexibility of a scripting system.
The C# samples below take advantage of CS-Script by providing K2 code that will run from a single C# file. For instance, you could open a DOS prompt and run a script as easily as this:
C:\> cscs.exe PlayClip.cs
To use these samples you will first need to setup your machine:
1. If you are writing code on a PC rather than the K2, install the Control Point software on your PC.
2. Next install CS-Script software:
- Download cs-script.zip. Extract it to "C:\Program Files". It will create a new directory called "C:\Program Files\cs-script".
- Next run "C:\Program Files\cs-script\css_config.exe". This will update system environment variables and bring up the configuration console. Press the "Close" button.
- To uninstall, run "C:\Program Files\cs-script\config.bat" and press 'Deactivate' button on the 'General' tab in the configuration console. It will undo any changes made byCS-Script installation.
3. (Optionally) Install a text editor that is good for code editing (recommendation: Notepad++.)
4. Save any of the examples below to your "c:\profile" directory, then at a DOS prompt run: "cscs.exe "
LivePlay.cs | shows how to play a live recording clip within 0.5 second of the record position. |
FlyingMixEffects.cs | shows how to create flying mix effects between the foreground and background contexts of a channel. |
PlaylistMixEffects.cs | shows how to create a playlist with section and event mix effects transitions. |
Samples: (click here to download all samples)
File | Description |
HelloWorld.cs | basic "Hello World" C# script demonstrating command-line arguments, getting input, printing out text, and returning an exit code |
BasicK2Connection.cs | script showing each K2 connection steps. It shows you the basic calls you need to get started |
K2ScriptTemplate.cs | a better K2 connection script template that encapsulates several of the connection calls in one connection object. makes for easier code reading. |
GetSystemStatus.cs | get system status |
LogMessage.cs | log a message |
PlayClip.cs | play a clip |
RecordClip.cs | record a clip |
ScheduledPlay.cs | play a clip at a scheduled time |
ScheduledRecord.cs | record a clip at a scheduled time |
CopyClip.cs | copy a clip |
DeleteClip.cs | delete a clip |
TransferaClip.cs | transfer a clip |
GetVersion.cs | get system version information |
GetDiskSpace.cs | get disk space |
GetChannelOwner.cs | get channel owner information |
GetAssetProperties.cs | get properties of a clip |
GetChannelProperties.cs | get channel properties |
CreateBin.cs | create a bin |
GetXmlChanges.cs | get XML change information |
ClipCacheCalls.cs | demonstrates calls needed to efficiently build a clip cache |
EnumerateVolumes.cs | enumerate the volumes |
MonitorTransfers.cs | monitor transfers |
PlayList.cs | create a play list |
RecordAndRenameClip.cs | record clip, get editor, rename clip |
viewmovie.cs | view movie attributes |
GetTimecode.cs | get the current timecode of a player |
InsertEditTwoHead.cs | demonstrates how to do insert edits and use two heads for playback |
PlayerCreateSubclip.cs | create a subclip from a clip loaded in a player |
MediaMgrCreateSubclip.cs | create a subclip from a clip NOT loaded in a player |
ImportDeleteTracks.cs | shows how to import, delete, move, and label tracks in a clip |
AddAncillaryData.cs | shows how to merge, replace, and add ancillary data to a clip |
LoadSaveConfig.cs | shows how to load a configuration from or save a configuration to a local file. |
SetAssetARC.cs | set aspect ratio conversion on a clip-by-clip basis. |
GenerateAsRunLog.cs | generate an as-run log by parsing the log file for played clips. |
DisplayPlayedAssets.cs | displays just played asset names in a playing playlist. |
GetSetTrackLabels.cs | get and set a clip's track labels. |
GetInfoFromClipXML.cs | get information from a clip's XML representation. |
SplitAndCombineEdits.cs | how to split and combine a clip's edits |