1

I want to know the equivalent for getMCRef().attachAudio() in openlaszlo 4.9. Earlier i used this method to get the audio input to a view to displace based on the audio. But in the recent version i tried attaching it to the sprite but it's not working. Any ideas?

karthick
  • 11,998
  • 6
  • 56
  • 88
  • What are you exactly trying to do? Access the microphone and record audio using a Red5 or Wowza? – raju-bitter Sep 22 '12 at 20:14
  • @RajuBitter: I was just trying to get the activity level of the microphone in OL3.3 version i wont get the activity level unless and other wise i attach the audio to the movie clip. In OL 4.9, i tried adding it to sprite but it didn't work. But later i wrote a component in AS3 to get the activity level and its working. – karthick Sep 24 '12 at 11:30
  • Right, in ActionScript2 / Flash 8 it was possible to access the microphone through the MovieClip reference, but the API has changed for ActionScript 3. You might want to answer your own question, and you can accept your own answer as well. – raju-bitter Sep 26 '12 at 09:10

1 Answers1

1

This code snippet should get you started, it shows you how to access the Flash Microphone and Camera object from OpenLaszlo SWF8, SWF9 and SWF10 run-time in OpenLaszlo 4.9.0:

<class name="mediamanager">

  <when property="$as3"><!-- SWF9, SWF10 -->

    <passthrough>
      import flash.media.*;
    </passthrough>

    <!---
    Gets a reference to the camera.

    @returns object: reference to the camera object.
    -->
    <method name="getMicrophone">
      return flash.media.Microphone.getMicrophone();
    </method>

    <method name="getNumMics">
      return flash.media.Microphone.names.length;
    </method>   

    <method name="getMicNames">
      return flash.media.Microphone.names;
    </method>           

  </when>

  <when property="$as2"><!-- SWF8 -->

    <!---
    Gets a reference to the camera.

    @returns object: reference to the camera object.
    -->
    <method name="getMicrophone">
      return Microphone.get();
    </method>

   <method name="getNumMics">
     return Microphone.names.length;
   </method>        

   <method name="getMicNames">
      return Microphone.names;
   </method>        

</when>

<when property="$as3"><!-- SWF9, SWF10 -->

<passthrough>
  import flash.media.*;
</passthrough>

<!---
Gets a reference to the camera.

@returns object: reference to the camera object.
-->
<method name="getCamera">
  return flash.media.Camera.getCamera();
</method>

<method name="getNumCams">
  return flash.media.Camera.names.length;
</method>   

<method name="getCamNames">
  return flash.media.Camera.names;
</method>       

</when>

<when property="$as2">

 <!---
 Gets a reference to the camera.

 @returns object: reference to the camera object.
 -->
<method name="getCamera">
  return Camera.get();
</method>

<method name="getNumCams">
  return Camera.names.length;
</method>

<method name="getCamNames">
  return Camera.names;
</method>

</when>

</class>

See the Flash documentation for the Flash Microphone and Camera object for full details of their properties and methods. Also, this is not the official way to access the Microphone and Camera in OpenLaszlo, but I used them because not all the properties were available from the OpenLaszlo camera and mic API, if you want to use the official API see the official class documentation at:

http://www.openlaszlo.org/lps4.9/docs/reference/ - "Audio Video" folder

Kmeixner
  • 1,664
  • 4
  • 22
  • 32