nwebb

Flex, Flash, AIR

Archive for the 'video' Category

Full Screen Video

Tonight I've been playing around with video in Flex and I also decided to check out the full-screen option which first became available in Flash player version 9,0,28,0. I rarely get to play with video and I have had a lot of fun :]

nwebb Flex video app

I thought I'd make a few notes for anyone who's interested, and I may post up an example in the next few days if there's any interest in it.

A Non Event in Moxie
It may be worth noting that the class flash.events.FullScreenEvent is missing from the Flex Moxie M2 (Beta). It's a known issue, so I'd suggest that Flex users probably stick to creating video projects in FlexBuilder2 for the time being.

Parenting Skills
I stuck a VideoDisplay object on the stage, added a button to go full screen and modified the html template as described in the help files - that was straight forward enough. Then I decided to put my video in some layout containers. When you do this and go full screen the containers obviously go full-screen too and that may not be what you want, so that led me on to my first ever need for a bit of re-parenting. I wanted to remove the containers and re-parent the video so that only the flv was showing in full-screen mode.

Thankfully I stumbled upon a really neat bit of code from Ted Patrick:

Actionscript:
  1. if( instanceName )
  2.              if( instanceName .parent ) instanceName .parent.removeChild( instanceName );

As Ted explains, this reads as: if the instance exists and the instance is attached to the display list, remove it through itself. I was easily able to remove the containers and re-parent the video so that it displayed full-screen - then add back in the containers and re-parent the video again when the user exited full-screen. It should be noted that the stage property only becomes available on applicationComplete, so you can't add the event listener for FullScreenEvent.FULL_SCREEN until then (i.e. this event is needed for catching when the user escapes out of full-screen mode using the escape key)

Also, I was initially looking for some kind of complete video display component such as you find for Flash, but could only see the VideoDisplay component which only displays the video and doesn't have a built in progress bar or buttons. I've not really had a good look to double-check that I haven't overlooked anything (and besides it won't be too hard to build something from scratch) but the apparent lack of such a component surprised me a bit.

2 comments

Bad Behavior has blocked 399 access attempts in the last 7 days.