“Start” and “End” on Playback tab “Time Selection Mode” on Smart Client Plugin.

Hi,

Please let us know how to read the “Start” and “End” times, when we select “Time Selection Mode” on on Playback for Smart Client Plug-in,

Thanks

Shaminda

You can use a message.

“SmartClient.GetTimelineSelectedIntervalRequest”

https://doc.developer.milestonesys.com/html/index.html?base=miphelp/class_video_o_s_1_1_platform_1_1_messaging_1_1_message_id_1_1_smart_client.html&tree=tree_search.html?search=smartclient.gettimelineselectedintervalrequest

You can see it in use in the Message Tester plugin sample.

https://doc.developer.milestonesys.com/html/index.html?base=samples/pluginsamples/messagetester/readme.html&tree=tree_1.html

Hi Andersen,

Thanks for the quick response, I was trying to set StartTime and EndTime on “MIPSDK\PluginSamples\SCExport” SDK sample on video export (ref below code), appreciate if you can able guide me on how to change this get start and end times from the “Time Selection” on playback tab,

    SCExportJob job = new SCExportJob()

    {

      Item = \_selectedItem,

      **StartTime** = DateTime.Now - TimeSpan.FromSeconds(15),

      **EndTime** = DateTime.Now,

      FileName = \_selectedItem.Name + ".avi",

Path = PATH,

AVIexport = true,

      OverlayImage = overlayImage,

      VerticalOverlayPosition = VideoOS.Platform.Data.AVIExporter.VerticalOverlayPositionTop,

      HorizontalOverlayPosition = VideoOS.Platform.Data.AVIExporter.HorizontalOverlayPositionLeft,

      ScaleFactor = 0.1,

      IgnoreAspect = false

    };

Do this code change to the SCExport sample and test if it works for you.

// properties introduced to ensure a default behavior
private DateTime _timeStart = DateTime.Now - TimeSpan.FromSeconds(15);
private DateTime TimeStart
{
    get
    {
        return _timeStart;
    }
    set
    {
        if (value == DateTime.MinValue)
        {
            _timeStart = DateTime.Now - TimeSpan.FromSeconds(15);
        }
        else
        {
            _timeStart = value;
        }
    }
}
private DateTime _timeEnd = DateTime.Now;
private DateTime TimeEnd
{
    get
    {
        return _timeEnd;
    }
    set
    {
        if (value == DateTime.MinValue)
        {
            _timeEnd = DateTime.Now;
        }
        else
        {
            _timeEnd = value;
        }
    }
}
 
// Changed in the SCExport sample, same way change also OnAVIExport_Click and OnMKVExport_Click
private void OnDBExport_Click(object sender, RoutedEventArgs e)
{
    SetTimesFromTimelineSelectedInterval();  //inserted
    if (_selectedItem != null)
    {
        Directory.CreateDirectory(PATH);
        SCExportJob job = new SCExportJob()
        {
            Item = _selectedItem,
            StartTime = TimeStart, //changed
            EndTime = TimeEnd,     //changed
            FileName = TruncateName(_selectedItem.Name),
            Path = PATH,
            AVIexport = false,
            SignExport = (bool)SignExport.IsChecked,
            PreventReExport = (bool)PreventReExport.IsChecked
        };
        SCExportBackgroundPlugin.AddJob(job);
    }
}
 
// the GetTimelineSelectedIntervalRequest is done and the result is delivered by setting the two properties
private void SetTimesFromTimelineSelectedInterval()
{
    string all = "";
    Message message = new Message(MessageId.SmartClient.GetTimelineSelectedIntervalRequest, null, null);
    try
    {
        var response = EnvironmentManager.Instance.SendMessage(message, null, null);
        if (response != null && response.Count > 0)
        {
            all = response[0].ToString();
        }
        else
        {
            TimeStart = DateTime.MinValue;
            TimeEnd = DateTime.MinValue;
            return;
        }
    }
    catch (Exception ex)
    {
        EnvironmentManager.Instance.ExceptionDialog("SCExport-MessageRequest", ex);
    }
    string[] seperator = new string[] { " - " };
    string[] result = all.Split(seperator, StringSplitOptions.RemoveEmptyEntries);
    TimeStart = GetDateTime(result[0]);
    TimeEnd = GetDateTime(result[1]);
}
 
// parse the string from the result to datetime
// important; the datetimes are in UTC, will be delivered and used later still in UTC
// important; the string format and the parsing is depending on the culture in which the SC runs
public static DateTime GetDateTime(string date)
{
    DateTime datetimeParsed = DateTime.Parse(date, System.Threading.Thread.CurrentThread.CurrentUICulture);
    datetimeParsed = DateTime.SpecifyKind(datetimeParsed, DateTimeKind.Utc);
    return datetimeParsed;
}

Thanks Bo Andersen ! Great Support !