grass valley developers

Home > APIs > AppServer API > Examples > Timeline and Transport Control > Record a 5 Second Clip

Record a 5 Second Clip

Below is code showing how to record a 5 second clip:

  1. A clip with a unique name is first generated in the V:\default bin.
  2. Next, the clip is cued on the recorder at the start of the clip.
  3. The recording length is set to 5 seconds (note: recording length can be given as a timecode string or a long number of fields).
  4. Recording is then started and 10 seconds later the clip is ejected.

You can view the clip's properties in AppCenter's MediaMonitor.

[C#]
bool isNewController = false;

// create a controller
ISimpleController icontroller = iappServer.CreateController(
"YourApplicationName", "C1", out isNewController);

// cast the controller to an ISimplePlayerRecorder interface.
ISimplePlayerRecorder recorder = (ISimplePlayerRecorder) icontroller;

// generate a new clip name in the V:\default bin
recorder.SetCurrentBin("V:", "default");
string newclip = recorder.GenerateUniqueName("test", "_");

// create the new clip, cue the record, and set the record length to 5 seconds
recorder.New(newclip);
recorder.CueRecord(0);
recorder.SetRecordLength("00:00:05.00");
recorder.Record();

// wait for 10 seconds only to show the record stopping at 5 seconds
Thread.Sleep(10000);

// eject clip and close channel
recorder.Eject();
icontroller.CloseChannel();
[C++]
short nIsNewController;
ISimpleControllerPtr spController;
_variant_t varChanNum(m_bstrChannel);
 
// create the controller
HRESULT hr = spAppServer->CreateController(m_bstrAppName, varChanNum, 
 &nIsNewController, &spController);

// generate a new clip name in the V:\default bin
spController->SetCurrentBin(_bstr_t("V:"), _bstr_t("default"));
BSTR bstrNewClip;
hr = spController->GenerateUniqueName(_bstr_t("test"), _bstr_t("_"), &bstrNewClip);

// cast the controller to a recorder
ISimplePlayerRecorderPtr spRecorder = (ISimplePlayerRecorderPtr) spController;

// create the new clip, cue the record, and set the record length to 10 seconds
spRecorder->New(bstrNewClip);
spRecorder->CueRecord(0);
spRecorder->SetRecordLength(_bstr_t("00:00:05.00"));
spRecorder->Record();

// wait for 10 seconds only to show the record stopping at 5 seconds
Sleep(10000);

// eject clip and close channel
hr = spRecorder->Eject();
hr = spController->CloseChannel();