GPU Preference Selection in AIR

AIR 28 has a feature where the AIR desktop application can be set to have a preference for the use of a specific GPU type:

  • The “discrete” (dedicated) for better performance, or
  • The “integrated” for better battery life.

This preference is set during the AIR application publication, thus ensuring that existing AIR content is not affected by this feature.

The new attribute in the application descriptor

For this feature, the gpuPreference attribute is introduced in the AIR application descriptor. AIR developers can specify either discrete or integrated for the attribute value to set a GPU preference. When the gpuPreference attribute is absent, the GPU type used is OS dependent, as is the case with previous versions of AIR.

<gpuPreference>(discrete|integrated)</gpuPreference>

Note: The value of the gpuPreference does not affect AIR applications that are launched by AIR Debug Launcher (ADL).

The support configuration for the feature

This feature is supported only on devices that are equipped with both an integrated GPU and a discrete GPU, and with OSes that support GPU switching functionality. Such a setup is more common on laptops than on desktops. This feature has been tested on Windows 10 devices equipped with Nvidia or AMD graphic cards, and Mac OS X version 10.12. In some cases, the effectiveness of the GPU preference selection has been device driver dependent.

Effectiveness of GPU Preference Selection.

Setting of the gpuPreference attribute does not guarantee the use of a GPU by the AIR application at all times. OS policies and device driver vendor tools settings may override the AIR gpuPreference attribute setting.

Note: AIR runtime forces Stage3D applications to use discrete GPU on Mac regardless of the value of the gpuPreference attribute. The intention of this enforcement is to avoid expensive cost of preparing the Stage3D rendering again such as loading of the GPU resources for adapting the change in the GPU type.

How to detect the assigned GPU type

The GPU type assigned to the AIR application can be detected by two ways, through a tool or a through a programmatic method. The detection works only when the renderMode attribute is set to direct.

Scout1) is a useful debugging tool to detect what GPU is assigned to an AIR application. GPU information is provided in “Session Info” in Scout, as shown in the following image.

Figure 1 : GPU information captured on Mac

Figure 2:GPU information captured on Windows

Known issues with the current version of Scout:

  • GPU information is not shown when an AIR application runs on top of DirectX11 on Windows 8 or above.
  • Scout lacks the ability to show proper GPU information if the GPU type being used is changed while the application is running. In such a scenario, AIR application needs to be relaunched so that Scout can capture what the current GPU is in the given setting.

The programmatical method to detect the GPU type assigned is through the use of the driver property of the StageVideoAvailablityEvent event. When AIR application registers an event handler for the StaveVideoAvailability event, the StageVideoAvailablityEvent event will fire upon assignment of the GPU type. In the event listener, the GPU information can be retrieved by use of the driver property. As a note, the driver property is available for AIR applications authored for SWF 26 or above.

References

  1. Getting Started With Adobe Scout : http://www.adobe.com/devnet/scout/articles/adobe-scout-getting-started.html

Feathers 3.4

Congratulations to Josh Tynjala and the Feathers open source project for the release of Feathers 3.4. Feathers offer a large collection of ActionScript user interface components and layouts for mobile, desktop, and smart TVs. It is powered by both Starling Framework and Adobe AIR.

What’s new in this release?

In version 3.4.0, Feathers UI includes a new DataGrid componentsorting for collections, and updates to the FocusManager and all components to support TV remote controls when targeting Android TV.

Data Grid

The new DataGrid component displays data in a table format with multiple columns for each item in its data provider. It supports re-ordering columns, column resizing, and sorting items.

Let’s take a moment to learn the basics of the Feathers DataGrid component. First, instantiate the component and add it to the display list:

var grid:DataGrid = new DataGrid();
this.addChild( grid );

Next, populate the grid’s data provider with some items:

var items:ArrayCollection = new ArrayCollection(
[
    { item: "Chicken breast", dept: "Meat", price: "5.90" },
    { item: "Bacon", dept: "Meat", price: "4.49" },
    { item: "2% Milk", dept: "Dairy", price: "2.49" },
    { item: "Butter", dept: "Dairy", price: "4.69" },
    { item: "Lettuce", dept: "Produce", price: "1.29" },
    { item: "Broccoli", dept: "Produce", price: "2.99" },
    { item: "Whole Wheat Bread", dept: "Bakery", price: "2.49" },
    { item: "English Muffins", dept: "Bakery", price: "2.99" },
]);
grid.dataProvider = items;

As you can see, each item contains multiple fields, and we want to display each of them in its own columns. To do that, define another collection:

grid.columns = new ArrayCollection(
[
    new DataGridColumn("item", "Item"),
    new DataGridColumn("dept", "Department"),
    new DataGridColumn("price", "Unit Price"),
]);

For each column, specify the field to access from each item, and also specify a more human-readable label for the column header.

That’s it! You have created your first DataGrid in Feathers.

Get started with Feathers 3.4.0

You can find the Feathers UI 3.4.0 release notes on the project’s Github page. Developers are encouraged to download the latest stable build from the Feathers website.

Adobe AIR applications installation issue

This technote addresses the installation issue of Adobe AIR applications after 30th Oct 2017 that is signed with SHA1 certificate. It is applicable to both Windows and Mac.

Issue

When you install your AIR application, the installation fails with the below error. The error dialog is a generic installation failure message that could occur for various reasons. One of them is due to signature validation failure.

Who should use this solution?

If your developed AIR application fails to install after 30th Oct 2017.

Issue confirmation

Follow the steps below to verify if the signature validation failure is the cause of the installation failure:

  1. Open the application installation logs. The location of the log files for different platforms is mentioned in the article: https://helpx.adobe.com/air/kb/logging-air-2-desktop-application.html
  2. If the installation log contains the error: “Package signature validation failed”, it indicates that the application is signed with SHA1 certificate.
  3. Set your system date to a date prior to 30th Oct 2017, and try to install the application again. Successful installation confirms that your application is impacted by the signature validation issue.

Solution

You will have to re-sign your Adobe AIR application. Follow the steps below to re-sign your application:

  1. Rename your Adobe AIR application by changing its extension from .air to .zip. In case you don’t see the extension in the filename, enable the filename extension before renaming the application.
  2. Extract the .zip file renamed in Step 1.
  3. Go to the extracted folder and perform the following modifications (in the order specified):
    1. Move xml present inside META-INF\AIR\ folder to the root of the extracted folder.
    2. Delete “META-INF” folder.
    3. Delete “mimetype” file located in the root of the extracted folder.
  4. Download the latest AIR SDK for your platform from http://www.adobe.com/devnet/air/air-sdk-download.html.
  5. Locate the AIR SDK archive file downloaded in Step 4 and extract the AIR SDK Compiler (if on Windows) or mount the AIR SDK Compiler dmg (if on Mac).
  6. Open the command prompt and change the current working directory to the root directory of the extracted AIR application directory.
  7. Use the command below to re-package the AIR application with a new certificate:
<AIR_SDK_compiler_path>\bin\adt –package -storetype pkcs12 -keystore  <app_signing_certficate_path> myApp.air application.xml .

Command line parameters:

  1. AIR_SDK_compiler_path – Location of AIR SDK compiler extracted or mounted in Step 5.
  2. app_signing_certficate_path – Fully qualified path of your application signing certificate. Make sure you are using SHA256 certificate.
  3. myApp.air – Name of the application to be packaged.
  4. application.xml – The file that was moved in Step 3.A

When prompted, enter the password of your application signing certificate.

Note:
Do not ignore the . (dot) at the end of the packaging command above. It is used to package all the resources present in your existing application. For more details on packaging AIR applications, refer https://help.adobe.com/en_US/air/build/WS901d38e593cd1bac1e63e3d128cdca935b-8000.html.

Workaround

AIR applications with the above-mentioned issue can be installed using two methods.

Using keyboard shortcuts: 

Install the Adobe AIR Runtime

Steps to follow on Windows:

1. Go to C:\Program Files (x86)\Common Files\Adobe AIR\Versions\1.0

2. While holding the “Ctrl” key,  select the Adobe AIR Application Installer.exe -> Right click on it -> Run as Administrator. Do not take your finger off the “ctrl” key until you see the window open up.

3. Select and open the AIR application to be installed.

Steps to follow on Mac:

1. Go to /Applications/Utilities

2. While holding the “command” key,  double click on the Adobe AIR Application Installer.  Do not take your finger off the “command” key until you see the window open up.

3. Select and open the AIR application to be installed.

The Adobe AIR Application should be installed successfully.

Using the new -ignoreExpiredCertificateTimestamp directive while launching AIR Application installer using Command Prompt/Terminal

Install the Adobe AIR Runtime

Steps to follow on Windows:

1. Open a command prompt as Administrator.

2. Run the following command:

“C:\Program Files (x86)\Common Files\Adobe AIR\Versions\1.0\Adobe AIR Application Installer.exe” – ignoreExpiredCertificateTimestamp

3. Window opens up.

4. Select and open the AIR application to be installed.

Steps to follow on Mac:

1. Open Terminal.

2. Run the following command:

/Applications/Utilities/Adobe\ AIR\ Application\ Installer.app/Contents/MacOS/Adobe\ AIR\ Application\ Installer/ -ignoreExpiredCertificateTimestamp

3. Window opens up.

4. Select the AIR application to be installed.

Adobe AIR Applications gets installed successfully.

Feathers 3.2

Congratulations to Josh Tynjala and the Feathers open source project for the release of Feathers 3.2. Feathers offers a large collection of ActionScript user interface components and layouts for mobile and desktop. It is powered by both Starling Framework and Adobe AIR.

What’s new in this release?

In version 3.2.0, Feathers UI includes a new PullToRefresh example, a new swipe gesture for TabNavigator, real time collection filtering, and support for asynchronous texture uploads with the ImageLoader component.

Collection filtering

The new filterFunction property in the ListCollection class makes it possible to filter data in real time. To illustrate this functionality, let us create a quick example that uses a TextInput component to filter the items in a List component.

Firstly, we will create the List and TextInput. Then we will populate the ListCollection with some data:

var data:Array =
[
	{ label: "Apple" },
	{ label: "Banana" },
	{ label: "Cherry" },
	{ label: "Grape" },
	{ label: "Lemon" },
	{ label: "Peach" },
	{ label: "Strawberry" },
	{ label: "Watermelon" },
];
var collection:ListCollection = new ListCollection(data);

var list:List = new List();
list.dataProvider = collection;
this.addChild(list);

var input:TextInput = new TextInput();
this.addChild(input);

Now, we would like to filter the items displayed in the List when the TextInput is modified. To accomplish this, we will listen for Event.CHANGE and modify the filterFunction property:

input.addEventListener(Event.CHANGE, function():void
{
   if(input.text.length === 0)
   {
       collection.filterFunction = null;
       return;
   }
   collection.filterFunction = function(item:Object):Boolean
   {
       var itemText:String = item.label.toLowerCase();
       var filterText:String = input.text.toLowerCase();
       return itemText.indexOf( filterText ) >= 0;
   };
});

The filterFunction is called for each item in the ListCollection. If it returns true, the item is displayed and if it returns false, the item is hidden.

Get started with Feathers 3.2.0

You can find the Feathers UI 3.2.0 release notes on the project’s Github page. Developers are encouraged to download the latest stable build from the Feathers website.

Fixing the ‘timestamp’ error when packaging an AIR app for desktop

Adobe Flash Builder

Adobe Flash Builder 4.7 is an Integrated Development Environment (IDE) for developing games and applications using ActionScript and Flex framework.

Error description

When packaging an AIR application for desktop, you might encounter an error- “Could not generate time-stamp: Remote host closed connection during handshake”.

Solution

This error occurs due to the presence of Java 6 in Flash Builder. Please follow the steps below to fix this error:

Windows

  1. Run Flash Builder with Java 7/8 by following the steps mentioned in the article Running Flash Builder with Java 7/8.
  2. Add the line below in the FlashBuilder.ini file in the installation directory of Flash Builder.
-Djava.util.Arrays.useLegacyMergeSort=true

Mac

Run Flash Builder with Java 7/8 as mentioned in the article Running Flash Builder with Java 7/8.

Command Line/ Terminal

When packaging through command line (Windows) / Terminal (Mac), you need to set the Java version to 1.7 or 1.8 to avoid errors.

HSTS Support in Flash Player 23

fp_new_icon

By Vivek Negi

HSTS is an Internet Engineering Task Force (IEFT) standard that enforces the user-agents like browsers to use the secured HTTPS protocol for communication instead of the HTTP protocol. The HTPPS response header from a host may have a ‘Strict-Transport-Security’ (STS) header field, which requests the user-agent to always make subsequent requests to access that host using the HTTPS protocol only. Beginning with version 23, Flash Player supports the HSTS standard. Flash Player now acknowledges an STS header in the HTTPS responses received from the HSTS hosts.

HSTS support is particularly helpful in those Flash applications where an SWF calls another SWF (child) and this child SWF is located in an HSTS enabled host. When the parent SWF tries to access the child SWF, the host sends an STS header in the HTTPS response. This STS header is acknowledged by Flash Player. Therefore, all the subsequent requests for the child SWF by the parent SWF can be made only through the HTTPS protocol.

The figure below depicts a workflow of how the HSTS enabled hosts and the non-HSTS enabled hosts interact with the browsers and Flash Player.

hsts_workflow_diagram

In the figure above, the browser is loading a Flash application that has two SWFs ─ outer.swf denoting the parent SWF and inner.swf denoting its child SWF. The non-HSTS host doesn’t enforce the browser (user-agent) to use the secure protocol, that is, HTTPS. The workflow, as depicted in the figure above, when the browser accesses content from the HSTS enabled host is described below:

  1. The file container.html loads outer.swf in the HSTS Host (hsts.host.com).
  2. The browser sends out request #4 through the non-secure transport as the URI for outer.swf is specified with HTTP scheme in container.html.
  3. The browser receives a 301 Moved Permanently response from hsts.host.com as the server is an HSTS host and stops communicating using the non-secure HTTP protocol.
  4. Browser now sends out request #6 through the secure HTTPS protocol based on the Location header field as shown in the response #5 301 Moved Permanently.
  5. Browser receives the response #7 200 OK and notes hsts.host.com as a ‘Known HSTS Host’ as the response message has a Strict-Transport-Security (STS) header field. From this point onwards, any subsequent request to this host by the browser will be made using the HTTPS protocol.
  6. Browser passes the outer.swf stream to Flash Player with the response headers.
  7. Flash Player also notes hsts.host.com as a ‘Known HSTS Host’.
  8. Flash Player loads outer.swf and runs ActionScript in it.
  9. outer.swf loads inner.swf using URLRequest with the parameter http://hsts.host.com/inner.swf.
  10. The earlier versions of Flash Player, in the absence of HSTS support, would have made the request through the unsecured HTTP protocol. Flash Player 23, however, sends request #11 through secure transport as hsts.host.com is a ‘Known HSTS Host’.

HSTS support in Flash Player can be very useful in various aspects, but most importantly it makes Flash Player more secure than its previous versions.

Running Adobe Flash Builder on Win and Mac with Java 7/8

By Krati Rastogi and Vivek Kumar

Adobe® Flash® Builder® 4.7, which is an Integrated Development Environment (IDE) for developing games and applications using ActionScript and Flex framework runs on Java 6. If you do not have Java 6 on your machine Flash Builder does not launch and instead displays this error.

flash-builder

Steps to follow on Windows

  1. Install Java 1.7/1.8.
  2. Copy the jre7/jre8 folder inside the Java folder. Replace the jre folder inside flash builder installation folder with the copied one.
  3. Restart Flash Builder.

Steps to follow on Mac

    1. Set your JAVA_HOME to Java 7 or Java 8 as per the correct paths on your machine.
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home
    1. Open JVM’s Info.plist at $JAVA_HOME/../Info.plist and add the highlighted lines to JVMCapabilities array:arrays
    2. Create a symlink for libjvm.dylib as follows:
sudo mkdir –p /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bundle/Libraries
sudo ln -s /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/server/libjvm.dylib /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bundle/Libraries/libserver.dylib

Note: Correct the version number (in jdk1.7.0_79.jdk) path in the above example to make it point to the correct path on your machine.

  1. Set java.library.path by adding the following lines at the end of “/Applications/Adobe Flash Builder 4.7/Adobe Flash Builder 4.7.app/Contents/MacOS/Adobe Flash Builder 4.7.ini”.
-Djava.library.path=../../../eclipse/plugins/com.adobe.flexide.nativelibs_4.7.0.349722/os/macosx/:../../../eclipse/plugins/com.adobe.flexide.amt_4.7.0.349722/os/macosx/:../../../eclipse/plugins/com.adobe.flexbuilder.utils.osnative_4.7.0.349722/os/macosx/

Restart your machine and launch Flash Builder.

Possible error on Mac

If you are trying to launch Flash Builder on Mac OS 10.12 and you see an error such as:

java.lang.RuntimeException: Application "com.adobe.flexbuilder.standalone.FlashBuilderApplication" could not be found in the registry. The applications available are: org.eclipse.ant.core.antRunner, org.eclipse.ant.ui.antRunner, org.eclipse.equinox.app.error, org.eclipse.equinox.p2.director, org.eclipse.equinox.p2.garbagecollector.application, org.eclipse.equinox.p2.publisher.InstallPublisher, org.eclipse.equinox.p2.publisher.EclipseGenerator, org.eclipse.equinox.p2.publisher.ProductPublisher, org.eclipse.equinox.p2.publisher.FeaturesAndBundlesPublisher, org.eclipse.equinox.p2.reconciler.application, org.eclipse.equinox.p2.repository.repo2runnable, org.eclipse.equinox.p2.repository.metadataverifier, org.eclipse.equinox.p2.artifact.repository.mirrorApplication, org.eclipse.equinox.p2.metadata.repository.mirrorApplication, org.eclipse.equinox.p2.updatesite.UpdateSitePublisher, org.eclipse.equinox.p2.publisher.UpdateSitePublisher, org.eclipse.equinox.p2.publisher.CategoryPublisher, org.eclipse.help.base.infocenterApplication, org.eclipse.help.base.helpApplication, org.eclipse.help.base.indexTool, org.eclipse.jdt.apt.core.aptBuild, org.eclipse.jdt.core.JavaCodeFormatter, org.eclipse.ui.ide.workbench, org.eclipse.update.core.standaloneUpdate, org.eclipse.update.core.siteOptimizer.
 at org.eclipse.equinox.internal.app.EclipseAppContainer.startDefaultApp(EclipseAppContainer.java:248)
 at org.eclipse.equinox.internal.app.MainApplicationLauncher.run(MainApplicationLauncher.java:29)
 at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
 at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
 at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
 at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
 at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
 at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
 

Locate a directory named “p2” at /Applications/Adobe Flash Builder 4.7/ and delete it. Flash Builder should now launch.

Beta News – Flash Player NPAPI for Linux

Flash Player and Linux

Linux users have access to both NPAPI and PPAPI versions of Flash Player.  However, for the last four years, the NPAPI version has been held at 11.2 and regularly updated with only security fixes while the PPAPI version (used in Chrome and Chromium based browsers), is in line with the standard Windows and Mac releases.

Today we are updating the beta channel with Linux NPAPI Flash Player by moving it forward and in sync with the modern release branch (currently version 23).  We have done this significant change to improve security and provide additional mitigation to the Linux community.

In the past, we communicated that NPAPI Linux releases would stop in 2017.  This is no longer the case and once we have performed sufficient testing and received community feedback, we will release both NPAPI and PPAPI Linux builds with their major version numbers in sync and on a regular basis.

Because this change is primarily a security initiative, some features (like GPU 3D acceleration and premium video DRM) will not be fully implemented.

If you require this functionality, we recommend that you use the PPAPI version of Flash Player.  That said, we believe that the new NPAPI build represents a significant step forward in functionality, stability, and security and look forward to hearing your feedback.

Currently we are distributing 32 and 64 bit binaries only, we will package these in proper installers after additional testing and feedback. Users should manually back-up their existing Flash Player plugin file from the appropriate system plug-in folder and copy the new binaries into place to use them.  Please note that our initial release does not support Fedora based distributions.  For more information, see our release notes.

You can download the new NPAPI binaries today by visiting the Adobe Labs download page.

Feathers 3.0: A New Major Version

Congratulations to Josh Tynjala and the Feathers open source project for the release of Feathers 3.0. Feathers offers a large collection of ActionScript user interface components and layouts for mobile and desktop. It is powered by both Starling Framework and Adobe AIR.

feathers-3-dot-0-final

What’s new in this release?

Many of the changes in Feathers 3.0 can be found under the hood, including bug fixes and architecture improvements. This version lays a foundation for new components and features in future versions.

Improved Performance When Idle

Feathers apps benefit greatly from the architecture changes in Starling Framework 2.0. CPU usage in static scenes has dropped to nearly zero with Starling’s new skipUnchangedFrames property. This means that apps built with Feathers should use less battery, which makes them better citizens on mobile devices.

Just take a look at this comparison made by Adobe Scout that shows an idle Feathers 2.3 app compared with the same app running on Feathers 3.0:

feathers-idle-performance

Skinning

In Feathers 3.0, the developer experience gets better too. Let’s look at some of the skinning improvements.

The Scale9Image, Scale3Image, and TiledImage classes are no longer necessary in Feathers 3.0 because Starling 2.0 now supports these capabilities natively in the Image class using the scale9Grid and tileGrid properties.

Here’s an example of using the scale9Grid property with an Image:

var image:Image = new Image( texture );
image.scale9Grid = new Rectangle( 3, 2, 6, 3 );
image.width = 100;
addChild( image );

For components that have more than one state (such as a Button that can be up, down or disabled), Feathers includes a new ImageSkin class that accepts multiple textures.

ImageSkin works a lot like Starling’s Image class, but it adds a new setTextureForState() method that can be used to pass in additional textures. Take a look at this example of using ImageSkin to skin a Button component’s states:

var skin:ImageSkin = new ImageSkin( upTexture );
skin.setTextureForState( ButtonState.DOWN, downTexture );
skin.setTextureForState( ButtonState.DISABLED, disabledTexture );
skin.scale9Grid = new Rectangle( 3, 2, 6, 3 );
button.defaultSkin = skin;

Migrating from Feathers 2.x to 3.0

Feathers 3.0 includes many more improvements, and some of them may require changes to your existing Feathers apps. Please read through the Feathers 3.0 Migration Guide for complete details about upgrading to this new major version.

feathers-migration-guide

You may also want to review the Starling 2 Migration Guide because it provides specific hints about upgrading Starling.

Get started with Feathers 3.0.0

You can find the Feathers UI 3.0.0 release notes on the project’s Github page. Developers are encouraged to download the latest stable version from the Feathers website.

How to provide video rotation information to ActionScript as metadata

fp_air

By Jason Lee

Prior to Flash Player and AIR version 20, the Flash runtime does not correctly process the matrix field values in the Track Header Box and the Movie Header Box, as defined in the ISO specification ISO/IEC 14496-12:2008. As a result, in some instances, the user experiences an incorrectly resized and rotated video when the video is played back with Flash. The problem is particularly pronounced when playing videos that are recorded in portrait mode with old Android or iOS devices. This happens because these devices save video in landscape mode along with a matrix representing rotation transformation, when the users record the video in portrait mode.

Flash Player and AIR version 20 introduce a feature whereby video rotation meta-data is provided through ActionScript. This feature mitigates the problem discussed above by providing the video matrix information to ActionScript as a part of the meta-data object of the onMetaData event, an event handler of the NetStream object. This allows the ActionScript developers to render the video in the intended rotation matrix. It should be noted that the Flash Player engine does not automatically apply the video matrix information to the rendered video output, so as to avoid any resizing or rotation that is not intended by the ActionScript developer.

video-rotation-problem

The ActionScript code example below shows how to apply the rotation matrix to the Video object.

Note: The example assumes that the video is recorded along a matrix representing 90° clockwise rotation.

var video:Video = new Video();
 addChild(video);
 var nc:NetConnection = new NetConnection();
 nc.connect(null);
 var ns:NetStream = new NetStream(nc);
 ns.client = {};
 ns.client.onMetaData = ns_onMetaData;
 ns.client.onCuePoint = ns_onCuePoint;
 video.attachNetStream(ns);
 ns.play("Demo.mp4");
 
function ns_onMetaData(info:Object):void {
 trace("metaData");
 video.x = 0,
 video.y = 0;
 video.width = info.width;
 video.height = info.height;
 varmatrix:Matrix = video.transform.matrix; // Read old transform matrix of video object.
 varoldSize:Point = new Point(video.width, video.height);
 varnewSize:Point = new Point(Math.abs(info.matrix.transformPoint(oldSize).x), Math.abs(info.matrix.transformPoint(oldSize).y));
 matrix.translate(-(oldSize.x / 2), -(oldSize.y / 2));
 if (info.hasOwnProperty("trackHeaderBoxMatrix"))
 matrix.concat(info.trackHeaderBoxMatrix[0]); // Apply the matrix of the Track Header Box of Video Track provided by this feature to video object.
 // trackHeaderBoxMatrix is an array of MatrixObject because there can be one or more video tracks.
 if (info.hasOwnProperty("movieHeaderBoxMatrix"))
 matrix.concat(info.movieHeaderBoxMatrix); // Apply the matrix of the Movie Header Box provided by this feature to video object.
 matrix.translate((newSize.x / 2), (newSize.y / 2));
 video.transform.matrix = matrix; // Set new matrix to transform matrix of Video object.
 }
 function ns_onCuePoint(item:Object):void {
 trace("cuePoint");
 }

The feature works for NetStream objects using progressive download, which allows Flash runtime to download and directly parse a video file. However, this feature does not handle NetStream using RTMP or appendBytes, in which case, the matrix properties provided by this feature are not available. This feature provides the matrices for all file formats — MP4, M4V, F4V, and 3GPP in accordance with ISO specification ISO/IEC 14496-12:2008, when using progressive download. For all other file formats, such as FLV, the matrix properties provided by this feature are not available.

The matrix information provided by this feature can only be applied to an instance of the Video class. Therefore, with StageVideo, which uses GPU acceleration, for example, the matrix information is not applicable.

This feature introduces the following new properties of the object representing video meta-data, a parameter of onMetaData event handler:

  • Object.movieHeaderBoxMatrix: flash.geom.Matrix
  • Object.trackHeaderBoxMatrix: An array of flash.geom.MatrixtrackHeaderBoxMatrix is an array of MatrixObject because there can be one or more video tracks in a single video file.

If you are a Flash content developer and are having trouble getting a video to display in correct orientation, please try this new ActionScript functionality for handling video rotation meta-data.