Tuesday, October 26, 2010

Using the Microphone with the Flash Player to View Activity Levels

Flash Player Actionscript 3 Images
  1. Choose a microphone
  2. Click the close button.
  3. Allow access to activate microphone

Use the Microphone class to capture audio from a microphone attached to a computer running Adobe AIR. Use the Microphone class to monitor the audio locally. Use the NetConnection and NetStream classes to transmit the audio to Flash Media Server. Flash Media Server can send the audio to other servers and broadcast it to other clients running Adobe AIR.

A system might not have a microphone or other sound input device attached to it. You can use the Microphone.names property or the Microphone.getMicrophone() method to check whether the user has a sound input device installed. If the user doesn't have a sound input device installed, the names array has a length of zero, and the getMicrophone() method returns a value of null.

Calling the Microphone.getMicrophone() method without a parameter returns the first sound input device discovered on the user's system.

The Sound Player

  1. Create a dynamic text field with instance the name of activity_txt
  2. Create a dynamic text field with instance the name of width_txt.
  3. Create a dynamic text field with instance the name of status_txt
  4. Draw a line with instance the name of line_mc.

The Code

import flash.media.Microphone;

var myMic:Microphone = Microphone.getMicrophone();
Security.showSettings(SecurityPanel.MICROPHONE);
myMic.setLoopBack(true);
myMic.setUseEchoSuppression(true);
myMic.addEventListener(StatusEvent.STATUS, this.onMicStatus);

function onMicStatus(event:StatusEvent):void
{
if (event.code == "Microphone.Unmuted")
{
status_txt.text = "Microphone access was allowed.";
}
else if (event.code == "Microphone.Muted")
{
status_txt.text = "Microphone access was denied.";
}
}

stage.addEventListener(Event.ENTER_FRAME, stage_EnterFrame);
function stage_EnterFrame(e:Event)
{
line_mc.width = myMic.activityLevel*5;
activity_txt.text = "Activity: " + String(myMic.activityLevel) + "%";
width_txt.text = "Line_mc Width: " + String(line_mc.width) + "px";
}

  1. Calling the Microphone.setUseEchoSuppression() method with a parameter value of true reduces, but does not completely eliminate, the risk that audio feedback will occur.
  2. The activity level is an integer (whole number) from 0 – 100 (no volume/full volume).
  3. Test the SWF and if you have a microphone you will see the levels on the bar and text fields change.

ActionScript 3.0 Language and Components Reference Using the Microphone class

Adobe Releases Air 2.5 with Smartphone, Tablet and Television Support

AIR Flash Builder ActionScript 3
Adobe Releases Air 2.5 with Smartphone, Tablet Support

"With the release of Air 2.5, more than three million Flash developers can now build a single game or application and easily deploy it across multiple application stores and devices," said David Wadhwani, Adobe's senior vice president of Creative and Interactive Solutions. "This is a huge step forward for developers looking to build rich, engaging applications but who have historically had to incur the cost of building them separately for each device and platform."

Adobe Air technology is supported on a range of devices, including smartphones and tablets which are running on platforms like iOS, Android and Blackberry, as well as PC-based operating systems like Windows, Macintosh and Linux.

Adobe AIR for Android

AIR developers will be able to upload AIR applications to the Android Market to be distributed for free or sold to users. These users will be able to download AIR applications just like any native Android application. If the AIR runtime is not already installed on the Android device, users will automatically be directed to download the AIR runtime from the Android Market. We are currently working with Android device OEMs to preinstall AIR to further improve the user experience.

Adobe AIR for TV

To make the optimizations in AIR 2.5 for TV available to developers, we added new APIs and enhanced others, including enhancements to the Keyboard APIs, the new StageVideo API, new Native Extension capabilities for hardware manufactures, and our new content protection solution called Flash Access 2.0. Flash Access enables content creators to deliver high value content right to the living room by having a protected delivery path from source to playback, including hardware security on the device using the device's hardware accelerated AES and RSA cores and secure key stores. By providing this high level of security, content creators and studios can have the comfort they need to delivery the highest-value Hollywood content directly over the Internet to a living room device.

With the introduction of AIR 2.5 for TV, Adobe is super excited to have Samsung as a launch partner, bringing the best platform for building rich content together with the largest TV and Blu-ray maker. Samsung is a leader in opening up the TV, starting with their Free the TV Developer Day in August 2010. Adobe has been working with Samsung throughout the year, porting and optimizing AIR for TV to run exceptionally well on their platform to allow developers to create best-in-breed applications. For developers to distribute their content, Samsung Apps is a platform that enables consumers to download and purchase applications on their TVs and Blu-ray players that come from many sources and use many technologies. Note that Samsung Apps is also connected to the Adobe InMarket service, which gives Flash and AIR developers a one-stop-shop to distribute their content to all the different platforms and devices that are enabled by Adobe AIR.

ADC article Optimizing Video and Content for Flash Platform on TV.

The impact of the new Air platform will be felt, especially as more and more devices begin to enable Flash. Already one of the top free apps on Android Market, Flash for Android brings rich Flash based content to mobile devices inside the browser.

New Adobe AIR Desktop Features

  1. CSS @font-face support
  2. CSS shadow support.
  3. StageWebView
  4. H.264 video hardware decoding for Windows.

Adobe Edge, a prototype for creating animation and transitions with HTML5

Adobe Fellow Mark Anders provides a sneak peek of a tool codenamed "Edge," a prototype of a tool for creating animation and transitions using the capabilities of HTML5.

Flash Catalyst Panini Preview

Flex 4 Flash Catalyst

With Flash Catalyst "Panini," Adobe is continuing to evolve the integration and collaboration of designers and developers, while providing additional capabilities to enable greater designer productivity when creating application user interface designs.

Features

  1. Resizable applications and components
  2. Extensive workflow enhancements
  3. Designer productivity enhancements
Adobe Flash Catalyst Panini

More from AdobeTV

Adobe AIR Launchpad 2.0 with Mobile Support

AIR Flash Builder Flash Video
Version 2.0 of Adobe AIR Launchpad Beta

Version 2.0 of Adobe AIR Launchpad Beta is now available and supports the creation of AIR Mobile projects as well as some other important updates (start a new project or switch back and forth between mobile or desktop AIR projects without restarting the app)!

Version 2.0 allows you to create mobile projects based on the AIR for Android APIs and the Flex Hero SDK's. You can now choose Desktop or Mobile for your application and have a zip file and directory folder containing all of your options with samples that can be imported into Flash Builder. The Desktop option targets the Flash Builder 4 IDE and the Mobile option targetes the Flash Builder Burrito IDE which is still in development.

  1. Download Adobe AIR Launchpad 2.0
  2. Install Adobe AIR Launchpad.
  3. Run Adobe AIR Launchpad and select the capabilities your application needs from the dialog boxes. Launchpad will generate the Flex or Burrito project.
  4. Import the resulting project and build your application.
  5. Ask questions or share your feedback in the Adobe AIR Launchpad forum

More from Adobe Labs

Related Posts Plugin for WordPress, Blogger...