1 Reply Latest reply on Apr 23, 2010 4:19 AM by jcastelain

    Invisible parallel element and bitmapData




      I'm to rather new to AS3 and completely new to OSMF and so I hope somebody here can help me with the following.

      I want to make an application that plays two simultaneous streams (I suppose using parallel elements), where on of the streams is not visible on the stage/canvas. Of this second stream I would like to access the bitmapData to display it in another way (moving thumbnails of other videos).


      So I have two questions:

      First, how would I go about creating an element that doesn't show on the stage.

      And second, how do I get at the bitmapData of an element in OSMF.


      I hope somebody can help. Thanks, Heerko

        • 1. Re: Invisible parallel element and bitmapData
          jcastelain Level 1

          Hi Heerko,


          To make an element "invisible" you can check the LayoutMetadata class

          import org.osmf.layout.LayoutMetadata;
          import org.osmf.media.MediaElement;
          // element is the MediaElement you want to be invisible
          var metadata:LayoutMetadata = element.getMetadata(LayoutMetadata.LAYOUT_NAMESPACE) as LayoutMetadata;
          if (!metadata) {
              metadata=new LayoutMetadata();
              element.addMetadata(LayoutMetadata.LAYOUT_NAMESPACE, metadata);
          metadata.x = 0;
          metadata.y = 0;
          metadata.width =  0;
          metadata.height = 0;   // Setting width and height to 0 will make it look like if it was not visible


          Probably not the best solution, but does the work


          Now for your BitmapData question


          import flash.display.BitmapData;
          import flash.display.DisplayObject;
          import org.osmf.net.NetStreamDisplayObjectTrait;
          import org.osmf.traits.MediaTraitType;
          // Let's say you're loading a video for example
          // element is a VideoElement instance here
          var trait:NetStreamDisplayObjectTrait = element.getTrait(MediaTraitType.DISPLAY_OBJECT) as NetStreamDisplayObjectTrait;
          if(trait) {
              var d:DisplayObject = trait.displayObject as DisplayObject;
              var b:BitmapData = new BitmapData(d.width, d.height);
              b.draw(d); // Watch out though, if you're loading from a different domain, make sure you have set/loaded policy files, etc ...

          Hope it helps