Sending a PlaybackCommand to a FloatingWindow

Hello,

I’m trying to open a floating window in playback mode with a given camera. My code looks like this approx:

var screenItems = Configuration.Instance.GetItemsByKind(Kind.Screen);
if (screenItems == null || !screenItems.Any())
{
    return;
}
 
var windowItems = Configuration.Instance.GetItemsByKind(Kind.Window);
if (windowItems == null || !windowItems.Any())
{
    return;
}
 
var cameraItem = ConfigAPIUtil.GetCameraWithMacOrId(cameraId);
if (cameraItem == null)
{
    return;
}
 
var viewAndLayoutItem = GetOrCreateView(tabTitle, "1 x 1", 1, cameraItem.FQID.ObjectId);
 
var commandData = new MultiWindowCommandData
{
    Screen = screenItems.First().FQID,
    Window = windowItems.First().FQID,
    View = viewAndLayoutItem.FQID,
    MultiWindowCommand = MultiWindowCommand.OpenFloatingWindow,
    PlaybackSupportedInFloatingWindow = true                
}; 
 
try
{
    var response = EnvironmentManager.Instance.SendMessage(new Message(MessageId.SmartClient.MultiWindowCommand, commandData));
    var popupWindowFQID = (FQID)response[0];
    EnvironmentManager.Instance.SendMessage(new Message(MessageId.SmartClient.ChangeModeCommand, clientMode), popupWindowFQID);
 
    if (clientMode == Mode.ClientPlayback)
    {                    
        var thread = new Thread(() =>
        {
            Thread.Sleep(2000);
            //ClientControl.Instance.CallOnUiThread(() =>
            //    EnvironmentManager.Instance.PostMessage(new Message(MessageId.SmartClient.PlaybackCommand, new PlaybackCommandData() { Command = PlaybackData.PlayStop }))); // popupWindowFQID
            
            var startDateTime = // Set up the start datetime
            ClientControl.Instance.CallOnUiThread(() =>
                EnvironmentManager.Instance.PostMessage(new Message(MessageId.SmartClient.PlaybackCommand, new PlaybackCommandData() { Command = PlaybackData.Goto, DateTime = startDateTime }), popupWindowFQID));
        });
        thread.IsBackground = true;
        thread.Start();       
    }
}
catch (Exception ex)
{
    Logger.Log(ex);
}

The problem that I have is that the PlaybackCommand, the one with Command = PlaybackData.Goto does not seem to be executed, the time of the floating window that gets opened is the current desktop time, not the startDateTime value.

The ChangeModeCommand gets executed all right.

Thanks for your time.

Please try to remove the Thread.Sleep, if it does not help try to drastically increase the wait. I think I remember the issue being that you should not introduce a wait as it will actually be disruptive.

Also try to do the Goto and then the ChangeModeCommand immediately after (no wait), reversing the order of the two.

When you have tested this let me have your observations.

Thanks for the asnwer, Bo.

Couldn’t make the Goto command to work but I ended up using a MessageId.SmartClient.ShowCamerasInFloatingWindowCommand and a MessageId.SmartClient.MultiWindowCommand with MultiWindowCommand.MaximizeWindow

which looks more straight forward.

So you still have the issue that you cannot Goto the time you want?