I was playing around with the Silverlight 4 beta and was trying to get my webcam working by following this article. Although the code to achieve this is very simple, the webcam did not work in my *.aspx page which contains my Silverlight component. I googled and stackoverflowed around but didn't find anyone with the same problem as I had. When the page loaded, I just saw an empty rectangle and Silverlight did not ask for permission to access my webcam like it should.
This is how the component looked in Firefox and this was the code, it’s the same as in the article:
Then I realized that all examples I saw on the web used a button before enabling the webcam. So I changed my component a little: added a 'Turn on camera' button and copied the code to start the camera to the click event of the button. If I now clicked the button, Silverlight asked for permission to use the webcam.
So the resulting code looked like:
And I was a happy coder, because I could now see myself in the webcam.
I documented this for everyone who might have the same problem. I don’t know if this is a known bug or not I didn’t find any documentation or ticket about it.