I have this code for live view from camera using BitmapLiveSource
public void OpenLiveSession(ConcurrentDictionary<Guid, FQID> CameraFqidDict, string cameraId, string wId)
{
try
{
widgetId = wId;
// if (CameraFqidDict.TryGetValue(new Guid(cameraId), out FQID fQID))
// {
Guid cameraGuid = new Guid(cameraId);
Item _selectedItem = Configuration.Instance.GetItem(cameraGuid, Kind.Camera);
if (_selectedItem != null)
{
_bitmapLiveSource = new BitmapLiveSource(_selectedItem, BitmapFormat.BGR24);
_bitmapLiveSource.LiveContentEvent += BitmapLiveSourceLiveContentEvent;
_bitmapLiveSource.Width = 480;
_bitmapLiveSource.Height = 320;
_bitmapLiveSource.SetKeepAspectRatio(true, true);
_bitmapLiveSource.Init();
_bitmapLiveSource.LiveModeStart = true;
_bitmapLiveSource.SingleFrameQueue = true; // New property from MIPSDK 2014
// _stopLive = false;
}
// }
}
catch (Exception ex)
{
EnvironmentManager.Instance.Log(true, "OpenLiveSession", ex.Message);
}
}
public void BitmapLiveSourceLiveContentEvent(object sender, EventArgs e)
{
try
{
var args = e as LiveContentEventArgs;
if (args != null)
{
if (args.LiveContent != null)
{
var bitmapContent = args.LiveContent as LiveSourceBitmapContent;
if (bitmapContent != null)
{
/* if (_stopLive || imageBox.Width == 0 || imageBox.Height == 0)
{
bitmapContent.Dispose();
}
else*/
int width = bitmapContent.GetPlaneWidth(0);
int height = bitmapContent.GetPlaneHeight(0);
int stride = bitmapContent.GetPlaneStride(0);
IntPtr plane0 = bitmapContent.GetPlanePointer(0);
//IntPtr newPlane0 = _transform.Perform(plane0, stride, width, height); // Make the sample transformation / color change
Bitmap myImage = new Bitmap(width, height, stride, PixelFormat.Format24bppRgb, plane0);
//string base64 = ImageUtils.ToBase64String(myImage, ImageFormat.Png);
ImageConverter converter = new ImageConverter();
byte[] imgBytes = (byte[])converter.ConvertTo(myImage, typeof(byte[]));
StringBuilder sb = new StringBuilder("subscriberForLiveVideoCards(");
sb.Append(JsonConvert.SerializeObject(imgBytes))
.Append(",\"")
.Append(widgetId)
.Append("\"")
.Append(");");
Task<JavascriptResponse> task = CameraUtil.ChromiumWebBrowser.EvaluateScriptAsync(sb.ToString());
task.ContinueWith(t =>
{
if (!t.IsFaulted)
{
EnvironmentManager.Instance.Log(false, "ProcessEventForFrontend", "Called subscriberForStatusCards JavaScript Function");
}
});
myImage.Dispose();
bitmapContent.Dispose();
}
}
else if (args.Exception != null)
{
// Handle any exceptions occurred inside toolkit or on the communication to the VMS
Bitmap bitmap = new Bitmap(320, 240);
Graphics g = Graphics.FromImage(bitmap);
g.FillRectangle(Brushes.Black, 0, 0, bitmap.Width, bitmap.Height);
if (args.Exception is CommunicationMIPException)
{
g.DrawString("Connection lost to server ...", new Font(System.Drawing.FontFamily.GenericMonospace, 12),
Brushes.White, new PointF(20, 100));
}
else
{
g.DrawString(args.Exception.Message, new Font(System.Drawing.FontFamily.GenericMonospace, 12),
Brushes.White, new PointF(20, 100));
}
g.Dispose();
Bitmap myBitmap = new Bitmap(480, 320, g);
//string base64 = ImageUtils.ToBase64String(myBitmap, ImageFormat.Png);
StringBuilder sb = new StringBuilder("subscriberForLiveVideoCards(");
sb.Append(JsonConvert.SerializeObject(myBitmap))
.Append(",\"")
.Append(widgetId)
.Append("\"")
.Append(");");
Task<JavascriptResponse> task = CameraUtil.ChromiumWebBrowser.EvaluateScriptAsync(sb.ToString());
task.ContinueWith(t =>
{
if (!t.IsFaulted)
{
EnvironmentManager.Instance.Log(false, "ProcessEventForFrontend", "Called subscriberForStatusCards JavaScript Function");
}
});
bitmap.Dispose();
}
}
}
catch (Exception ex)
{
EnvironmentManager.Instance.Log(true, "BitmapLiveSourceLiveContentEvent", ex.Message);
}
}
I need to get play back for a given date time.
How can i get playback instead of live video