Sep 01 2011

Making Stagevideo backwards compatible.

Published by at 1:17 pm under AS 3.0,Flash

In my earlier blog post i mentioned how the user needs Flash Player 10.2 for Stagevideo to work but if you want to make sure that your video player is compatible with older versions of Flash some changes need to be done.

The trick to achieve this is not to use any stagevideo classes and make them generic and we need to add a timer to check if the stagevideo event is fired or not. To demonstrate this i am going to use the sample code presented in this article and make same code compatible with 10.1 and older versions of the Flash Player.

If you look at the code the classes which cause problem are stagevideo specific classes i.e. flash.media.StageVideo or flash.events.StageVideoAvailability etc, these are not present in 10.1 and older so we have to get rid of those.

Some tricks that i have used is to remove the event classes and reference the individual events with strings. for eg.

1
container.stage.addEventListener(StageVideoAvailabilityEvent.STAGE_VIDEO_AVAILABILITY, onStageVideoState);

is replaced by,

1
container.stage.addEventListener("stageVideoAvailability", onStageVideoState);

this shouldn’t change in future releases if flash hopefully but if it does then you have to change your code unfortunately.

One additional thing to note is that the above event won’t get fired in 10.1 and older flash versions so we add a 1 second timer to detect if this event is fired or not. This allows us to fall back on using regular video to play our media file.

The modified class and the original class which are included in the flex project can be downloaded here for comparison.

One response so far

One Response to “Making Stagevideo backwards compatible.”

  1. […] No Backward Compatibility, if you use the stagevideo classes then the user needs to have 10.2 installed, Flash player will throw an exception otherwise. I have created a hack to use stagevideo and make it backwards compatible but its not out of the box. blog post about it […]

Trackback URI | Comments RSS

Leave a Reply