Skip to main content
Colin Holgate
Inspiring
August 7, 2014
Question

AIR 15 and iOS StageVideo

  • August 7, 2014
  • 2 replies
  • 1123 views

Do you have any sample code for StageVideo, that is capable of playing embedded H.264 .mp4 files? With AIR 14 I have not been able to achieve that. My suspicion is that StageVideo is failing somehow, and the fallback of playing H.264 netstream in a Video object doesn't seem to work. Does it now work with the automatic fallback?

Playing remote video with StageVideo in iOS works fine in AIR 14.

This topic has been closed for replies.

2 replies

Colin Holgate
Inspiring
August 7, 2014

So, I managed to figure out the reasons why StageVideo sometimes wouldn't kick in, and also why when it kick in it would crash on exit.

Sample code online shows to use this:

StageVideoAvailabilityEvent.STAGE_VIDEO_AVAILABILITY

It turns out that in iOS that event may have happened already, before the point where you add the listener. I've changed things to be like this:

if ( stage.stageVideos.length >= 1 ) {

       _enableStageVideo();

  }else{

       _stage.addEventListener(StageVideoAvailabilityEvent.STAGE_VIDEO_AVAILABILITY, _onStageVideoAvailability);

  }

Most times the stage.stageVideos has settled down, and there's no need to listen for the availibility.

The crashing on exit was because you can't do this:

_stagevideo.attachStream(null);

_ns.close(); //etc

you have to do this:

_ns.close(); //etc

_stagevideo.attachStream(null);

So, that just leaves a request here of sample code for the AIR 15 way of working. Under AIR 14 I have all the Video fallback code too, and it would be nice to strip that out.

August 11, 2014

I just had to say thank you for including this little snip of code as I never would have thought to check to see if the StageVideo objects were already available before my player was done initializing. I have been working on a giant media package for audio and video players on and off for a year now and hadn't even considered that as a possibility for StageVideo.

What are your thoughts on AIR15 beta currently including a default Video object fallback and always reporting "available" even when it isn't? If the Flash Player doesn't provide a reference to the Video object it generates and adds to the display list, it seems like that could cause the developer to have to do a little more work to properly remove the Video object for garbage collection. Im currently going by the information in the release notes as I haven't had time to download the beta and check out the updated API to see if it does do this.

Colin Holgate
Inspiring
August 11, 2014

My bet is that if it transparently uses video if need be, it also transparently gets rid of it when you dispose of stage video.

Colin Holgate
Inspiring
August 7, 2014

To add to this, sometimes local StageVideo does work, but always when it does work the app goes on to crash when the stream is closed. That remains true in AIR 15.