Showing posts with label flash. Show all posts
Showing posts with label flash. Show all posts

Thursday, August 1, 2013

Flash acoustic echo cancellation

Acoustic echo cancellation (AEC) is required for voice-over-IP (VoIP) applications to provide headset-free talk. AEC is available in messenger applications (such as Skype and Google Talk) and softphones (such as Xlite).

In Flash, to use acoustic echo cancellation, call the Microphone.getEnhancedMicrophone() method to get a reference to a Microphone instance. Set Microphone.enhancedOptions to an instance of the MicrophoneEnhancedOptions class to configure settings. When AEC is not supported, Microphone.getEnhancedMicrophone() returns null.

Here are sample codes:
var mic:Microphone = Microphone.getEnhancedMicrophone();
var options:MicrophoneEnhancedOptions = new MicrophoneEnhancedOptions();
options.mode = MicrophoneEnhancedMode.FULL_DUPLEX;
options.echoPath = 128;
options.nonLinearProcessing = true;
mic.enhancedOptions = options;
There are two other settings similar but not exactly for acoustic echo cancellation.
  1. setUseEchoSuppression - this method can reduce, but not eliminate, the risk of feedback amplification. When enhanced audio is used, this echo suppression functionality is ignored.
  2. noiseSuppressionLevel - Maximum attenuation of the noise in dB (negative number) used for Speex encoder. If enabled, noise suppression is applied to sound captured from Microphone before Speex compression. Set to 0 to disable noise suppression. Noise suppression is enabled by default with maximum attenuation of -30 dB. Ignored when Nellymoser codec is selected.
References:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/package-detail.html
http://www.adobe.com/devnet/flashplayer/articles/acoustic-echo-cancellation.html

Sunday, December 2, 2012

Select HTML5 Video/Audio Player

There are many HTML5 Video and audio players which support native HTML5 audio/video tags with flash/silverlight fallback to support non-modern browsers. Selecting appropriate player among a big list needs more research effort, so finding the right one for your web application depends on your web app requirement and design. Even your web app doesn't need support non-modern browsers, I still suggest to use one HTML5 media player because different browsers support different video/audio codecs.

Web app requirement and design usually include the following points:
1. Do you want a unified UI/API for native HTML5 and flash fallback?
2. Do you need this on iOS (or other mobile browsers)?
3. Do you need the skinnable player?
4. Do you need the player support both video and audio?
5. What kind of license do you accept?

Among the big list and google results, I finally referenced the below 3 links to narrow down my choices
http://praegnanz.de/html5video/
http://html5video.org/wiki/HTML5_Player_Comparison
http://websitesmaderight.com/2011/05/45-html5-media-players-tutorials-and-resources/ 

For Video
video.js (LGPLv3)
SublimeVideo (Service/licensed)
JW Player (Custom)
flowplayer (GPLv3/Commercial)

For Audio
audio.js (MIT)
SoundManager (BSD)

For both Video and Audio
mediaelement.js (GPLv2 & MIT)
jplayer.js (GPL/MIT))
pickle player (licensed/purchase)
jMediaelement(GPL/MIT)
html5media.info (CC BY-NC-ND 3.0)

I want to find a player to support both Video and Audio, license free, working on iOS and with different themes for visual happiness. From above shorter list, I probably go with mediaelement.js (Paul Irish also recommends this player).

Friday, September 2, 2011

Javascript and Flash communication

In previous blog two errors when javascript calls flash methods I listed out 2 major errors when Javascript calls Flash methods. That was one way communication, but actually Flash can also call Javascript functions. Here is a quick summary about the typical two way communications between these 2 web technologies.

Flash (ActionScript):
ExternalInterface.call(“JS_FunctionName”, [args]); // calls a JavaScript function from inside your Flash or Actionscript file, passing arguments as additional parameters after the string function name of the JavaScript function.

ExternalInterface.addCallback(“ExposedName4JS”, AsMethod); // exposes the ActionScript method AsMethod to javascript under the javascript function name ExposedName4JS, which is passed as a string.


Javascript:
1. Get the Flash object
function getFlashObject(name)
{
  if (window.document[name])
  {
      return window.document[name];
  }
  if (navigator.appName.indexOf("Microsoft Internet")==-1)
  {
    if (document.embeds && document.embeds[name])
      return document.embeds[name];
  }
  else //IE uses object, FF uses embed, getElementById only works for <object> tag
  {
    return document.getElementById(name);
  }
}

2. Call flash method
getFlashObject("name").ExposedName4JS();

HTML:
<object id="name" data="mymovie.swf" width="640" height="360" type="application/x-shockwave-flash" >
    <param name="allowfullscreen" value="true">
    <param name="allowscriptaccess" value="always">
    <param name="wmode" value="opaque">
    <param name="flashvars" value="backgroundColor=#ffffff">
    <embed name="name" src="mymovie.swf" swliveconnect="true" quality="high" bgcolor="#FFFFFF" width="640" height="360" type="application/x-shockwave-flash">
    </embed >
</object >

Random notes:
1. SWFObject is an easy-to-use and standards-friendly method to embed Flash content, which utilizes one small JavaScript file http://code.google.com/p/swfobject/
2. Flash is not fully loaded when the body's onload event fires or domcontentloaded event fires. At least it is true in Chrome.
3. IE doesn’t destroy instances of the flash correctly when a page is reloaded, suggest to reset the instance like below
if(navigator.appName.indexOf(‘Microsoft Internet’) != -1)
   window[this._id] = new Object();

Sunday, August 28, 2011

Two errors when javascript calls flash methods

There are two frequent errors I met when I writing javascript and flash communication codes.

1. Error calling method on NPObject!
This error usually means Flash side exception, it might be caused by Flash itself error handling logic, or caused by wrong parameters passed to Flash from Javascript.

2. Uncaught TypeError: Object #<HTMLObjectElement> has no method 'xxx'
This error usually means flash object is not available or no such a method, it might be caused by flash object is not fully loaded, or not found the correct object, or call the wrong flash method (from Flash ExternalCallInterface).