I'm trying to preview one MediaCapture to multiple(2) CaptureElement's. For example I have one big CaptureElement and one mini - map of it in the screen corner. Is it possible?
When I'm trying to set initialized Capture to one CaptureElement, everything works fine, but when I share it in 2 places, I'm getting error like "unsupported operation for current state".
Here's the code example, I'm trying to use:
await video.TryStopPreviewingAsync();
minimap.Source = null;
await minimap.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
minimap.Source = video.Stream.Capture;
});
await video.TryStartPreviewingAsync();
minimap is second CaptureElement,video.Resources.First.Stream.Capture is currently previewing capture.
TryStop/StartPreviewingAsynccalls Capture.Stop/StartPreviewingAsync()
I tried to stop previewing first capture, set it like a source in 2 places and then starts previewing on both captureelements, but I got error.
It's by design, and it will throw exception when pass the
Captureto multipleCaptureElement.For your scenario, the better way is use image control replace
CaptureElement, and process frame withMediaFrameReader, and then generate bitmap for each frame withinFrameArrived.And here is official code sample that you could refer to.