2 Replies Latest reply on Sep 29, 2011 9:04 AM by drkstr_1

    Need a way to close OSMF video stream (spark VideoDisplay)

    drkstr_1 Level 4



      I've been ignoring the effects of this bug for awhile, but now I'm at a point where I need to do something about it.


      Basically the issue is that if you stop a streaming video in a VideoDisplay, either by calling stop or setting it's source to null, the video element and accompanying OSMF baggage will never garbage collect. The temporary work around I've been using is to simply let the stream play out off stage, at which point it will clean up appropriately. This however is causing an unacceptable peak memory while it runs on a mobile device (which frequently transitions out views displaying video streams).


      I need a way to disconnect a video stream and clear it out of memory at a time of my choosing. I figured I would need to extend/patch the existing VideoDisplay, but after going through the source, I'm having a bit of trouble moving forward.


      Would someone kindly point me in the right direction?



      Many thanks!

        • 1. Re: Need a way to close OSMF video stream (spark VideoDisplay)
          S_Aleksey Level 1

          Check out my post in this http://forums.adobe.com/thread/904374?tstart=0 thread. Hope it helps.


          Best Regards, Aleksey

          • 2. Re: Need a way to close OSMF video stream (spark VideoDisplay)
            drkstr_1 Level 4

            I was able to implement a temporary work around by wrapping the VideoDisplay in a UIComponent, then removing the VideoDisplay when the UIComponent is popped off the stage. This will allow the rest of the view hierarchy to garbage collect while the VideoDisplay goes off to die on it's own when the stream is finished. This is not an ideal solution, but it's all I've got for now. I am still looking for a way to disconnect an active video stream (similar to how you can disconnect a RemoteObject).


            Here's the code that demonstrates the principal if anyone is having the same issue.


            public class VideoElementView extends UIComponent
                      public function VideoElementView()
                                this.addEventListener(Event.REMOVED_FROM_STAGE, removedFromStageHandler);
                      private var _videoDisplay:VideoDisplay;
                      override protected function createChildren():void
                                _videoDisplay = new VideoDisplay();
                                _videoDisplay.left = _videoDisplay.right = _videoDisplay.top = _videoDisplay.bottom = 0;
                                _videoDisplay.minWidth = _videoDisplay.minHeight = 0;
                      override protected function measure():void
                                this.measuredWidth = _videoDisplay.getPreferredBoundsWidth();
                                this.measuredHeight = _videoDisplay.getPreferredBoundsHeight();
                      override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
                                super.updateDisplayList(unscaledWidth, unscaledHeight);
                                _videoDisplay.setLayoutBoundsSize(unscaledWidth, unscaledHeight);
                                _videoDisplay.setLayoutBoundsPosition(0, 0);
                      private function destroyVideoDisplay():void
                                _videoDisplay = null;
                      protected function removedFromStageHandler(event:Event):void


            Add additional accessor properties and methods as needed.