Video recording through .NET

Hello,

I want to record Simulation video in Visual Components through .NET. Can anyone suggest any solution with an Example??

You can do something like this:

private IVideoRecordExporter videoRecorder = null;
private void StartRecording()
{
    // subscribe to simulation reset to stop video recording
    var app = IoC.Get<IApplication>();
    app.Simulation.SimulationReset += OnSimulationReset;
    // set and start video recording
    videoRecorder = IoC.Get<IVideoRecordExporter>();
    videoRecorder.Start();
    // start simulation
    var runTime = IoC.Get<ISimulationSettingViewModel>().SimulationRunTime;
    IoC.Get<ISimulationService>().SwitchRunState(runTime, 0);
}

private void OnSimulationReset(object sender, EventArgs e)
{
    // stop video recording
    string pathToSave = @"C:\Users\SomeUser\Desktop\video.avi";
    videoRecorder.Stop(IoC.Get<IUrlHelper>().LocalPathToUrl(pathToSave , false));
}

Hope it helps

Hi ccamilo,

Thanks for the reply.

I have used the same code, but it is not working at all.

My code is like this:

[Export(typeof(IPlugin))]
public class Class1 : IPlugin
{
public void Exit()
{

}

public void Initialize()
{

}
public IVideoRecorder videoRecorder = null;
public void StartRecording()
{
//Reset simulation to stop recording
var app = IoC.Get<IApplication>();
app.Simulation.SimulationReset += OnSimulationReset;

//Set and Start Video recording
videoRecorder = IoC.Get<IVideoRecordExporter>();
videoRecorder.Start();

//start simulation
var runtime = IoC.Get<ISimulationSettingViewModel>().SimulationRunTime;
IoC.Get<ISimulationService>().SwitchRunState(runtime, 0);

}

public void OnSimulationReset(Object sender, EventArgs e)
{
//Stop video Recording
string pathtosave = @“F:\WORK\video.avi”;
videoRecorder.Stop(IoC.Get<IUrlHelper>().LocalPathToUrl(pathtosave, false));
}

}

 

Please check and let me know where I am wrong.

I don’t see you are calling StartRecording() in your code. You should use this method whenever you want to start recording. Also, simulation should stop at some point in order to finish the recording process. At which point would you like to app to start recording the simulation?