What is the best practice to loop video?

I have registered to the PlaybackCurrentTimeIndication event and inspecting if the message data in the event handler has surpassed my end time in order to send a another GoTo Playback command.

private void Initialize()
{
	_ImageViewerControl = ClientControl.Instance.GenerateImageViewerControl();
	panel.Add(_ImageViewerControl);
 
	EnvironmentManager.Instance.RegisterReceiver(PlaybackTimeChangedHandler, new MessageIdFilter(MessageId.SmartClient.PlaybackCurrentTimeIndication));
}
 
private object PlaybackTimeChangedHandler(VideoOS.Platform.Messaging.Message message, FQID dest, FQID sender)
{
	DateTime time = (DateTime)message.Data;
 
	if (time > _PlaybackEndTime)
	{
		if (InvokeRequired)
		{
			BeginInvoke(new Action(() => PlaybackVideo(_PlaybackStartTime, _PlayBackEndTime)));
		}
		else
			PlaybackVideo(_PlaybackStartTime, _PlayBackEndTime);
	}
 
	return null;
}
 
private void PlaybackVideo(FQID cameraFQID, DateTime startTime, DateTime endTime)
{
	if (_ImageViewerControl.CameraFQID != null)
	{
		_ImageViewerControl.Disconnect();
		_ImageViewerControl.CameraFQID = null;
	}
 
	_ImageViewerControl.CameraFQID = cameraFQID;
 
	_ImageViewerControl.Initialize();
	_ImageViewerControl.Connect();
 
	_PlaybackStartTime = startTime;
	_PlayBackEndTime = endTime;
 
	EnvironmentManager.Instance.Mode = Mode.ClientPlayback;
 
	EnvironmentManager.Instance.SendMessage(new VideoOS.Platform.Messaging.Message(
		MessageId.SmartClient.PlaybackCommand,
		new PlaybackCommandData() { Command = PlaybackData.Goto, DateTime = startTime }));
 
	EnvironmentManager.Instance.SendMessage(new VideoOS.Platform.Messaging.Message(
		MessageId.SmartClient.PlaybackCommand,
		new PlaybackCommandData() { Command = PlaybackData.PlayForward, Speed = 1 }));
}

The reason for this post is because we are seeing a memory leak where the memory is slowly increasing until the system runs out of memory.

We have encountered this memory leak in both 2020R1 and the most recent 2020R2.

We have also tried Generating a PlaybackController FQID and passing that into ImageViewerControl as well as using it to call GetPlaybackController and use the PlaybackController’s SetSequence method instead of using SendMessage with PlaybackCommand GoTo.

This memory leak can be reproduced in component sample projects such as PlaybackUser by actively displaying recorded video for any extended period of time.

If you use the PlaybackController class you will see that in the class there is SetSequence which is for showing video in a loop, set the start and end time.

https://doc.developer.milestonesys.com/html/index.html?base=miphelp/class_video_o_s_1_1_platform_1_1_client_1_1_playback_controller.html&tree=tree_search.html?search=playbackcontroller

Please see Video Viewer Individual Playback sample on how to create and use the PlaybackController class-

https://doc.developer.milestonesys.com/html/index.html?base=samples/videoviewer2playback_sample.html&tree=tree_search.html?search=videoviewer2playback