3 Replies Latest reply on Mar 30, 2007 5:19 AM by Yann Martel

    Using the Webcam

    Yann Martel
      Hello everybody.

      I've spent hours trying to create a simple Flex application that displays the webcam video. And I can't get it right ?
      Is that even possible ? And if so, can anyone give me a script that does it ?

      Thanks.

        • 1. Re: Using the Webcam
          radekg
          Hi Yann,

          It is possible. Please take a look at the code below.

          ----------------------------------------------------------------------

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" creationComplete="this.onComplete();">

          <mx:Script>
          <![CDATA[
          import mx.core.UIComponent;
          import flash.media.*;

          private var _cam
          private var _mic:Microphone;
          private var _cameraVideo:Video;

          private function onComplete():void
          {
          this.createVideo();
          this.runCamera();
          }

          private function createVideo():void
          {
          this._cameraVideo = new Video(300, 200);
          var c1:UIComponent = new UIComponent();
          c1.width = 300;
          c1.height = 200;
          c1.addChild(this._cameraVideo);
          this.cntVideo.addChildAt(c1, 0);
          }

          private function runCamera():void
          {
          this._cam = Camera.getCamera();
          this._mic = Microphone.getMicrophone();
          this._cameraVideo.attachCamera(this._cam);
          }

          ]]>
          </mx:Script>

          <mx:HBox id="cntVideo" />

          </mx:Application>

          Are you experiencing any other issues?

          --
          Radek
          • 2. Re: Using the Webcam
            Yann Martel Level 1
            Thanks for your reply !
            In fact your code is quite similar to mine, I've tried it, and unfortunately, it doesn't work.
            I get the popup asking me if I want to use the webcam, but after that, nothing is displayed...

            I'm sure the webcam is working, I've tested it with another software... weird.

            • 3. Re: Using the Webcam
              Yann Martel Level 1
              Ok I finally found a solution. The code was perfect, the problem came from Flash Player that didn't have the right camera selected. I'm so stupid, wasting hours on such a dumb problem :(