5 Replies Latest reply on Jun 10, 2010 2:48 PM by bringrags

    Help me with the AdProxy Class

    box86rowh

      Hello,

      I have built a video player using osmf using rtmp streaming and now I want to add a 5 second text ad before the video starts.  I found the AdProxy class in the examples but cannot get it to display anything if I add it to my composition.  Anyone have any examples on how to use this class?

        • 1. Re: Help me with the AdProxy Class
          bringrags Level 4

          The AdProxy allows you to apply a DisplayObject (such as a label) on top of another DisplayObject (such as a video).  The latter DisplayObject comes from a separate MediaElement that you pass to the AdProxy's constructor.  So to use the AdProxy, you would need to assign a separate MediaElement to the AdProxy's constructor, and then add the AdProxy to a SerialElement (followed by the VideoElement that should follow it).  Note that if the MediaElement you're assigning isn't temporal by nature (such as an image or SWF), then you should wrap it in a DurationElement to make it temporal, playable, seekable, etc., e.g.:

           

          serialElement.addChild(new DurationElement(5, new AdProxy(new ImageElement(new URLResource("http://example.com/image.jpg")));

          1 person found this helpful
          • 2. Re: Help me with the AdProxy Class
            box86rowh Level 1

            Thanks a lot for your fast reply!

            I have tried what you have below and all I get is the Image in the stage without the text label showing. No errors or anything.

            I am using Flex 4 and loading my cff fonts at runtime so Im not sure if this would interfere with the text showing?

            I put a break point in the function that is called by the timer in adProxy, and I can see that the displayObject sprite as no parent, so Im not sure if it is getting added to the displayList, but I dont know where to look to troubleshoot this.

             

            Thanks Again,

            Jason

             

            Date: Wed, 9 Jun 2010 15:15:06 -0600

            From: forums@adobe.com

            To: jasonatsmtc@hotmail.com

            Subject: Help me with the AdProxy Class

             

            The AdProxy allows you to apply a DisplayObject (such as a label) on top of another DisplayObject (such as a video).  The latter DisplayObject comes from a separate MediaElement that you pass to the AdProxy's constructor.  So to use the AdProxy, you would need to assign a separate MediaElement to the AdProxy's constructor, and then add the AdProxy to a SerialElement (followed by the VideoElement that should follow it).  Note that if the MediaElement you're assigning isn't temporal by nature (such as an image or SWF), then you should wrap it in a DurationElement to make it temporal, playable, seekable, etc., e.g.:

             

            serialElement.addChild(new DurationElement(5, new AdProxy(new ImageElement(new URLResource("http://example.com/image.jpg")));

            >

            • 3. Re: Help me with the AdProxy Class
              box86rowh Level 1

              Update,

              I did get something to appear for me using the TextElement, so I think I will work from that as a starter, thanks for the help

              Jason

               

              Date: Wed, 9 Jun 2010 15:15:06 -0600

              From: forums@adobe.com

              To: jasonatsmtc@hotmail.com

              Subject: Help me with the AdProxy Class

               

              The AdProxy allows you to apply a DisplayObject (such as a label) on top of another DisplayObject (such as a video).  The latter DisplayObject comes from a separate MediaElement that you pass to the AdProxy's constructor.  So to use the AdProxy, you would need to assign a separate MediaElement to the AdProxy's constructor, and then add the AdProxy to a SerialElement (followed by the VideoElement that should follow it).  Note that if the MediaElement you're assigning isn't temporal by nature (such as an image or SWF), then you should wrap it in a DurationElement to make it temporal, playable, seekable, etc., e.g.:

               

              serialElement.addChild(new DurationElement(5, new AdProxy(new ImageElement(new URLResource("http://example.com/image.jpg")));

              >

              • 4. Re: Help me with the AdProxy Class
                box86rowh Level 1

                Another quick question,

                I got some text to show up ony my stage using the textElement example class, now I am trying to do something similar except I want to create a flex component that I can use as the display object instead of the textfield.  Here is my TextAdElement class that I am trying:

                 

                package classes
                {
                    import org.osmf.traits.DisplayObjectTrait;
                    import org.osmf.media.MediaElement;
                    import org.osmf.traits.MediaTraitType;
                   
                    public class TextAdElement extends MediaElement
                    {
                        public function TextAdElement(textTrait:DisplayObjectTrait)
                        {
                            super();
                            addTrait(MediaTraitType.DISPLAY_OBJECT, textTrait);
                        }
                    }
                }

                 

                here is the implementation code:

                 

                            public function getAd():MediaElement{
                                var ta:TextAd = new TextAd();
                                ta.width = 512;
                                ta.height = 288;
                                var tt:DisplayObjectTrait = new DisplayObjectTrait(ta,512,288);
                                var txt:TextAdElement = new TextAdElement(tt);
                                return new DurationElement(20,txt);
                            }

                 

                the TextAd object is just a group with a label in it for now, but I dont get anything on the stage during the 20 seconds where this is supposed to show.

                 

                Thanks

                Jason

                • 5. Re: Help me with the AdProxy Class
                  bringrags Level 4

                  I don't think we've tried very many cases of display list integration of Flex 4 Groups.  Does it display if you use an out-of-the-box Spark control (e.g. a Spark Label or Button)?  Might be good to isolate whether it's a Spark integration problem or a problem with your TextAd class.