Hello Bo, how are you? Thanks for your help!
I’m follow your advise and create a Independent Playback, now I have a ViewItemPlugin, right?
So I trying to insert this ViewItemPlugin in a FloatingWindow, the code for create the FloatingWindow are below:
private Object CameraListReceiver(VideoOS.Platform.Messaging.Message message, FQID destination, FQID source)
{
List<Alarm> alarms = message.Data as List<Alarm>;
if (alarms != null)
{
// Insert cameras
int index = 0;
foreach (Alarm alarm in alarms)
{
DataInfo dataJson;
using (StreamReader r = new StreamReader("C:\\Users\\milestone\\Desktop\\web_pages.json"))
{
string jsonString = r.ReadToEnd();
dataJson = JsonConvert.DeserializeObject<DataInfo>(jsonString);
}
int viewNumber = _viewCounter + 1;
// Make a new Temporary view group
ConfigItem tempGroupItem = (ConfigItem)ClientControl.Instance.CreateTemporaryGroupItem("Temporary" + viewNumber);
// Make a group
ConfigItem groupItem = tempGroupItem.AddChild("DynamicViewGroup" + viewNumber, Kind.View, FolderType.UserDefined);
// Build a layout with wide ViewItems at the top and buttom, and 5 small ones in the middle
Rectangle[] rect = new Rectangle[4];
rect[0] = new Rectangle(000, 000, 499, 499);
rect[1] = new Rectangle(499, 000, 499, 499);
rect[2] = new Rectangle(000, 499, 499, 499);
rect[3] = new Rectangle(499, 499, 499, 499);
//rect[4] = new Rectangle(599, 399, 199, 199);
//rect[5] = new Rectangle(799, 399, 199, 199);
//rect[6] = new Rectangle(000, 599, 999, 399);
int capacity = rect.Length;
string viewName = "DynamicView" + viewNumber;
ViewAndLayoutItem viewAndLayoutItem = groupItem.AddChild(viewName, Kind.View, FolderType.No) as ViewAndLayoutItem;
viewAndLayoutItem.Layout = rect;
if (alarm.EventHeader.Source.FQID.ObjectId.ToString() == dataJson.CameraID)
{
// Add camera from the triggering event
// Note: EventHeader.Source cannot be null because an alarm must have a source
if (index < capacity && alarm.EventHeader?.Source.FQID.Kind == Kind.Camera)
{
viewAndLayoutItem.InsertBuiltinViewItem(index++,
ViewAndLayoutItem.CameraBuiltinId,
new Dictionary<string, string>()
{
{ "CameraId", alarm.EventHeader.Source.FQID.ObjectId.ToString() }
});
}
if (alarm.ReferenceList == null)
continue;
// Add related cameras from the alarm
foreach (Reference rel in alarm.ReferenceList)
{
if (index < capacity && rel.FQID.Kind == Kind.Camera)
{
// PLAYBACK - TO DO INSERT PLAYBACK IN THE FLOATING WINDOW
viewAndLayoutItem.InsertViewItemPlugin(index++, ViewItemPlugin.,
new Dictionary<string, string>()
{
});
viewAndLayoutItem.InsertBuiltinViewItem(index++,
ViewAndLayoutItem.HTMLBuiltinId,
new Dictionary<string, string>()
{
{ "URL", $"{dataJson.URL}" },
{ "Scaling", "5"},
{ "HideNavigationBar", "true"},
{ "Addscript", "true"}
});
viewAndLayoutItem.InsertBuiltinViewItem(index++,
ViewAndLayoutItem.TextBuiltInId,
new Dictionary<string, string>()
{
{ "Text", $"Metadata: \n" +
$"Name: Joao \n" +
$"Gender: Male \n" +
$"Emotions: Happy\n" +
$"CameraID: {alarm.EventHeader.Source.FQID.ObjectId}"
}
});
}
}
}
else
{
// Add camera from the triggering event
// Note: EventHeader.Source cannot be null because an alarm must have a source
if (index < capacity && alarm.EventHeader?.Source.FQID.Kind == Kind.Camera)
{
viewAndLayoutItem.InsertBuiltinViewItem(index++,
ViewAndLayoutItem.CameraBuiltinId,
new Dictionary<string, string>()
{
{ "CameraId", alarm.EventHeader.Source.FQID.ObjectId.ToString() }
});
}
if (alarm.ReferenceList == null)
continue;
// Add related cameras from the alarm
foreach (Reference rel in alarm.ReferenceList)
{
if (index < capacity && rel.FQID.Kind == Kind.Camera)
{
viewAndLayoutItem.InsertBuiltinViewItem(index++,
ViewAndLayoutItem.HTMLBuiltinId,
new Dictionary<string, string>()
{
{ "URL", "www.google.com" }
});
viewAndLayoutItem.InsertBuiltinViewItem(index++,
ViewAndLayoutItem.HTMLBuiltinId,
new Dictionary<string, string>()
{
{ "URL", "www.milestonesys.com" }
});
viewAndLayoutItem.InsertBuiltinViewItem(index++,
ViewAndLayoutItem.EmptyBuiltinId,
new Dictionary<string, string>()
{ });
}
}
}
if (index == 0)
{
// Exit here, since no cameras were found in the alarm list
return null;
}
viewAndLayoutItem.Save();
tempGroupItem.PropertiesModified();
Item screen = Configuration.Instance.GetItemsByKind(Kind.Screen).FirstOrDefault();
Item window = Configuration.Instance.GetItemsByKind(Kind.Window).FirstOrDefault();
Item view = groupItem.GetChildren().FirstOrDefault(v => v.Name.Equals(viewName));
if (screen == null || window == null || view == null)
{
return null;
}
// Create floating window
MultiWindowCommandData data = new MultiWindowCommandData();
data.Screen = screen.FQID;
data.Window = window.FQID;
data.View = view.FQID;
data.X = 200;
data.Y = 200;
data.Height = 500;
data.Width = 500;
data.MultiWindowCommand = "OpenFloatingWindow";
data.PlaybackSupportedInFloatingWindow = true;
EnvironmentManager.Instance.SendMessage(new VideoOS.Platform.Messaging.Message(MessageId.SmartClient.MultiWindowCommand, data), null, null);
_viewCounter++;
}
}
return null;
}
So How can I relate the IndependentPlayback with the CameraId to show this playback in my FloatingWindow?
Att…
João Pedro