I get the above error when trying to set a PhotoCamera as source for a VideoBrush with the code:
camera = new PhotoCamera();
var videoBrush = new VideoBrush();
videoBrush.SetSource(camera);
AR.Background = videoBrush;
I get the following stack trace:
0x80131515
at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
at MS.Internal.XcpImports.VideoBrush_SetExternalVideoSource(VideoBrush vb, IntPtr& videoSessionHandle)
at System.Windows.Media.VideoBrush.SetUpExternalVideoSession()
at Microsoft.Devices.CameraVideoBrushExtensions.SetSource(VideoBrush brush, Camera camera)
at MyClass.MyFunction()
at System.Windows.Controls.Frame.FireEventHandler[T](EventHandler`1 handler, Object sender, OrientationChangedEventArgs args)
at Microsoft.Phone.Controls.PhoneApplicationPage.UIOrientationChange(ShellPageOrientation orientation)
The exception is thrown whether or not I am having the debugger attached.
Thanks.
All right, I now have solved this. I think the solution could be appreciated by others so here it is;
It seems it is not possible to assign a PhotoCamera as a source to a programmatically created VideoBrush, so I edited my xaml to contain a
This was followed up by a simpler code
Furthermore this code is contained in a OnOrientationChanged event, which appearently fires multiple times, so contained in a
the code runs smooth.