views:

28

answers:

0

I have a rather unique situation here. I have a Silverlight application that captures images and uploads them to a web server which is pretty standard, but a requirement I have is to allow the web designer to make their own buttons and controls (or to style them) that controls the application.

So I decided to use ScriptableMember functions inside of my Silverlight application that can activate each function in it.


function StartCapture()
{
     var control = document.getElementById("silverlightControl");

     if($("#VideoCaptureDevices option:selected").val() == -1)
     {
         alert("Please select a video capture device");
         return;
     }
     else
         control.Content.Page.StartCapture($("#VideoCaptureDevices option:selected").val());
}

That code calls a function that does a bunch of setting up of the webcam for preparation, but the line that is failing me is this:


if (CaptureDeviceConfiguration.AllowedDeviceAccess ||
CaptureDeviceConfiguration.RequestDeviceAccess())

That always returns false. According to the MSDN documentation RequestDeviceAccess() will essentially be a NOOP if a user action is not triggering it. It appears by my testing that in this case it is doing a NOOP and returning false.

Does anybody know how to get around this or if Javascript actions are not considered user actions to allow this to be triggered?