Loading and showing cameras from existing view as in smart client

Hello,

I would like to load and display the video from all the cameras simultaneously as you would in smart client application by clicking on the existing view in my own .net application.

Can you please share a sample of how to do it?

Thank you

There is no sample like this, in general the samples are small and have limited functionality, in parts also because smaller sample should be simpler to learn from.

The sample I most often recommend for showing camera, live and playback, is the ImageViewerClient sample. It only takes one camera.

https://doc.developer.milestonesys.com/html/index.html?base=samples/componentsamples/imageviewerclient/readme.html&tree=tree_2.html

Almost as popular is the VideoViewer sample, this is a step forward as it takes two cameras.

https://doc.developer.milestonesys.com/html/index.html?base=samples/componentsamples/videoviewer/readme.html&tree=tree_2.html

I guess your application will need to be able to show x cameras, depending on the view that should be used.

No standalone sample reads views and uses them the way the Smart Client does.

Reading views is possible by using the Rest API, Configuration API soap, and VideoOS.Platform.ConfigurationItems.

You can see it in use in the Config API Client.

https://doc.developer.milestonesys.com/html/index.html?base=samples/componentsamples/configapiclient/readme.html&tree=tree_2.html

This snippet of code will list your views and content..

using VideoOS.Platform;
using VideoOS.Platform.ConfigurationItems;
 
private void FindViewGroups()
{
	var ms = new ManagementServer(EnvironmentManager.Instance.MasterSite);
	var vgs = ms.ViewGroupFolder.ViewGroups;
	label1.Text = Environment.NewLine;
	foreach (var vg in vgs)
	{
		ShowViews(vg);
	}
}
 
private void ShowViews(ViewGroup viewGroup)
{
	if (viewGroup == null)
	{
		return;
	}
	label1.Text += "ViewGroup " + viewGroup.Name + Environment.NewLine;
	var viewfolder = viewGroup.ViewFolder;
	if (viewfolder != null)
	{
		var views = viewfolder.Views;
		foreach (var view in views)
		{
			label1.Text += "View " + view.Name + Environment.NewLine;
			ShowCameraInView(view);
		}
	}
 
	var vgChildFolder = viewGroup.ViewGroupFolder;
	if (vgChildFolder != null)
	{
		var vgChildGroups = vgChildFolder.ViewGroups;
		if (vgChildGroups != null)
		{
			foreach (var vgGroup in vgChildGroups)
			{
				if (vgGroup != null)
				{
					ShowViews(vgGroup);
				}
			}
		}
	}
}
 
void ShowCameraInView(View view)
{
	var viewItemChildItems = view.ViewItemChildItems;
	foreach (var viewItemChilldItem in viewItemChildItems)
	{
		XDocument viewElementData = XDocument.Parse(viewItemChilldItem.ViewItemDefinitionXml);
		var viewItemElement = viewElementData.Element("viewitem"); 
		var itemInfoElement = viewItemElement.Element("iteminfo");
		if (itemInfoElement != null)
		{
			var cameraidAttribute = itemInfoElement.Attribute("cameraid");
			if (cameraidAttribute != null)
			{
				label1.Text += "Camera id " + cameraidAttribute + Environment.NewLine;
			}
		}
	}            
}

There will be some work in developing a client that can use the views, unfortunately no sample can show you.

Thank you Bo.

Another quick question - can I be logged in to both platform sdk and configuration api from a single application?

Yes.

The answer was too short, I feel I should elaborate a bit. In the ConfigAPIClient sample it first logs in using the MIP SDK, later it uses the loginsettings to create a soap client. So you will not have log in twice. I still believe the answer is yes, but the sample shows best practice.