5 Replies Latest reply: Aug 11, 2014 2:12 PM by wadedwalker RSS

    AIR 15 and iOS StageVideo

    Colin Holgate CommunityMVP

      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.

        • 1. Re: AIR 15 and iOS StageVideo
          Colin Holgate CommunityMVP

          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.

          • 2. Re: AIR 15 and iOS StageVideo
            Colin Holgate CommunityMVP

            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.

            • 3. Re: AIR 15 and iOS StageVideo
              wadedwalker Community Member

              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.

              • 4. Re: AIR 15 and iOS StageVideo
                Colin Holgate CommunityMVP

                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.

                • 5. Re: AIR 15 and iOS StageVideo
                  wadedwalker Community Member

                  I (clearly) hadn't considered that. Im just used to being as tidy as possible about not having any memory leaks and properly shutting down every object after it is no longer being used. Im a bit of a control freak on that front, always wanting to be as optimized as possible.