13.08.2012 Views

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>ACTIONSCRIPT</strong> 3.0 DEVELOPER’S GUIDE<br />

Working with video<br />

Using the StageVideoEv<strong>en</strong>t.RENDER_STATE and VideoEv<strong>en</strong>t.RENDER_STATE ev<strong>en</strong>ts<br />

StageVideo and Video objects s<strong>en</strong>d ev<strong>en</strong>ts that inform applications wh<strong>en</strong> the display <strong>en</strong>vironm<strong>en</strong>t changes. These<br />

ev<strong>en</strong>ts are StageVideoEv<strong>en</strong>t.RENDER_STATE and VideoEv<strong>en</strong>t.RENDER_STATE.<br />

A StageVideo or Video object dispatches a r<strong>en</strong>der state ev<strong>en</strong>t wh<strong>en</strong> a NetStream object is attached and begins playing.<br />

It also s<strong>en</strong>ds this ev<strong>en</strong>t wh<strong>en</strong> the display <strong>en</strong>vironm<strong>en</strong>t changes; for example, wh<strong>en</strong> the video viewport is resized. Use<br />

these notifications to reset your viewport to the curr<strong>en</strong>t videoHeight and videoWidth values of the ev<strong>en</strong>t target<br />

object.<br />

Reported r<strong>en</strong>der states include:<br />

RENDER_STATUS_UNAVAILABLE<br />

RENDER_STATUS_SOFTWARE<br />

RENDER_STATUS_ACCELERATED<br />

R<strong>en</strong>der states indicate wh<strong>en</strong> hardware accelerated decoding is in use, regardless of which class is curr<strong>en</strong>tly playing<br />

video. Check the StageVideoEv<strong>en</strong>t.status property to learn whether the necessary decoding is available. If this<br />

property is set to “unavailable”, the StageVideo object cannot play the video. This status requires that you immediately<br />

reattach the NetStream object to a Video object. Other statuses inform your application of the curr<strong>en</strong>t r<strong>en</strong>dering<br />

conditions.<br />

The following table describes the implications of all r<strong>en</strong>der status values for StageVideoEv<strong>en</strong>t and VideoEv<strong>en</strong>t objects<br />

in Flash Player:<br />

VideoStatus.ACCELERATED VideoStatus.SOFTWARE VideoStatus.UNAVAILABLE<br />

StageVideoEv<strong>en</strong>t Decoding and pres<strong>en</strong>tation<br />

both occur in hardware. (Best<br />

performance.)<br />

VideoEv<strong>en</strong>t Pres<strong>en</strong>tation in software,<br />

decoding in hardware.<br />

(Acceptable performance on a<br />

modern desktop system only.<br />

Degraded full-scre<strong>en</strong><br />

performance.)<br />

Pres<strong>en</strong>tation in hardware,<br />

decoding in software.<br />

(Acceptable performance.)<br />

Pres<strong>en</strong>tation in software,<br />

decoding in software.<br />

(Worst case performancewise.<br />

Degraded full-scre<strong>en</strong><br />

performance.)<br />

Note: AIR 2.5 for TV does not define the VideoStatus class and does not decode H.264 in software. See the<br />

StageVideoEv<strong>en</strong>t class in the ActionScript 3 Refer<strong>en</strong>ce for details on AIR 2.5 for TV ev<strong>en</strong>t implem<strong>en</strong>tation.<br />

Color spaces<br />

Stage video uses underlying hardware capabilities to support color spaces. SWF cont<strong>en</strong>t can provide metadata<br />

indicating its preferred color space. However, the device graphics hardware determines whether that color space can<br />

be used. One device can support several color spaces, while another supports none. If the hardware does not support<br />

the requested color space, Flash Player attempts to find the closest match among the supported color spaces.<br />

To query which color spaces the hardware supports, use the StageVideo.colorSpaces property. This property<br />

returns the list of supported color spaces in a String vector:<br />

var colorSpace:Vector. = stageVideo.colorSpaces();<br />

To learn which color space the curr<strong>en</strong>tly playing video is using, check the StageVideoEv<strong>en</strong>t.colorSpace property.<br />

Check this property in your ev<strong>en</strong>t handler for the StageVideoEv<strong>en</strong>t.RENDER_STATE ev<strong>en</strong>t:<br />

Last updated 6/6/2012<br />

No GPU resources are available<br />

to handle video, and nothing is<br />

displayed. Fall back to a Video<br />

object.<br />

(N/A)<br />

518

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!