6 Replies Latest reply on Jan 20, 2010 11:51 AM by RyanOConnell

    sizing the MediaPlayerSprite

    nathan@blip.tv

      I have a mediaplayer sprite that i am adding to the stage via my main class (which extends sprite)

      I can not for the life of me get the display to scale down to a size...

       

      am i missing something?

       

      code below:

      package {
           //imports removed for brevity

          
           public class Stratos extends Sprite {
               
                //vars
                private var _videoDisplay:MediaPlayerSprite;
                private var _player:BlipPlayer;
               
                private var _progressBar:SimpleProgressBar;
                private var _videoSeekBar:SimpleProgressBar;
                              
               
                public function Stratos():void {
                     stage.scaleMode = StageScaleMode.NO_SCALE;
                     stage.align = StageAlign.TOP_LEFT;
                    
                     _player = new BlipPlayer('http://blip.tv/rss/whatever');
                     _player.addEventListener(BlipEvent.PLAYLIST_LOADED, onPlayerDataLoaded);
                    
                     _videoDisplay = new MediaPlayerSprite(_player);
                     _videoDisplay.scaleMode = ScaleMode.LETTERBOX;
                     _videoDisplay.width = 200;  //why do you hate me?
                     _addChild(_videoDisplay);
                }         

       

      I have also worked a bit with the MediaPlayerCapabilityChangeEvent and the DIMENSION_CHANGE events to attempt some resizing on those events, to no avail...

       

      I am sure that i am overlooking something, most likely something simple - can anyone point me in the correct direction?

      Thank You in advance,

      -Nathan

       

      note: this was for some reason posted in the general discussions. I have moved the thread to the developer section and deleted the previous post.

        • 1. Re: sizing the MediaPlayerSprite
          jerryhamby Level 1

          My approach is more of a manual one. I'm using a basic Sprite and the standard MediaPlayer.

           

          I just use scaleX and scaleY. This may or may not work with the MediaPlayerSprite, I just haven't tested.

           

          I'm resizing images, so I get the original size of the image, I know the destination size, so I do some math to

          come up with a percentage. That percentage I use with scaleX and scaleY.

           

          pMediaSprite.scaleX = percentage;

          pMediaSprite.scaleY =  percentage;

          pMediaSprite.x =  0;

          pMediaSprite.y =  0;

           

          I do this on ViewEvent.DIMENSION_CHANGE event. Sprite 8 still has a bug here, but they say it is

          fixed in Sprint 9, we'll see.

          • 2. Re: sizing the MediaPlayerSprite
            RyanOConnell

            I noticed you are not setting the height, is that on purpose?  It won't scale down if you don't specify the height as well as the width.

             

            -Ryan O'Connell

            • 3. Re: sizing the MediaPlayerSprite
              nathan@blip.tv Level 1

              Thanks Guys,

              but even adding in the height does not work for me either.

               

              all i am trying to do is scale the movie down to fit into a ceartain size.

              Is this the way that others are doing it?

               

              I tried using the method jerry proposed (assuming that pMediaSprite is MediaPlayer.view) earlier and that is when i added in the mediaPlayerSprite - I thought that had some special sauce that i knew nothing about.

               

              Any other help is greatly appreciated,

              Thank You,

              -Nathan

              • 4. Re: sizing the MediaPlayerSprite
                RyanOConnell Level 2

                I'll just post a working example, and maybe you can build from there  :

                 

                 

                package {

                import flash.display.Sprite;

                import flash.display.StageAlign;

                import flash.display.StageScaleMode;

                 

                import org.osmf.display.MediaPlayerSprite;

                import org.osmf.display.ScaleMode;

                import org.osmf.media.URLResource;

                import org.osmf.net.NetLoader;

                import org.osmf.utils.URL;

                import org.osmf.video.VideoElement;

                   

                     public class SimpleScalingVideoPlayer extends Sprite

                     {        

                          private var _videoDisplay:MediaPlayerSprite;

                          private static const REMOTE_PROGRESSIVE:String = "http://mediapm.edgesuite.net/strobe/content/test/AFaerysTale_sylviaApostol_640_500_short.f lv";

                      private var _player:VideoElement;

                 

                          public function SimpleScalingVideoPlayer():void

                          {         

                               stage.scaleMode = StageScaleMode.NO_SCALE;

                               stage.align = StageAlign.TOP_LEFT;

                 

                               _player = new VideoElement(new NetLoader());

                               _player.resource = new URLResource(new URL(REMOTE_PROGRESSIVE));

                 

                               _videoDisplay = new MediaPlayerSprite();

                               _videoDisplay.element = _player;

                               _videoDisplay.scaleMode = ScaleMode.LETTERBOX;

                               _videoDisplay.width = 100;  //why do you hate me?

                               _videoDisplay.height = 100;  //why do you hate me?

                               addChild(_videoDisplay);

                          }       

                     }

                }

                1 person found this helpful
                • 5. Re: sizing the MediaPlayerSprite
                  nathan@blip.tv Level 1

                  The difference is SerialElement v/s video element.

                  if i replace the video in your example with a serialElement that has a child video element, the sizing does not work at all.

                  Is that intended?

                   

                   

                  package {
                  import flash.display.Sprite;
                  import flash.display.StageAlign;
                  import flash.display.StageScaleMode;

                  import org.osmf.*;
                  import org.osmf.composition.SerialElement;
                  import org.osmf.display.MediaPlayerSprite;
                  import org.osmf.display.ScaleMode;
                  import org.osmf.media.URLResource;
                  import org.osmf.net.NetLoader;
                  import org.osmf.utils.URL;
                  import org.osmf.video.VideoElement;
                   
                       public class Example extends Sprite
                       {         
                            private var _videoDisplay:MediaPlayerSprite;
                            private static const REMOTE_PROGRESSIVE:String  = "http://mediapm.edgesuite.net/strobe/content/test/AFaerysTale_sylviaApostol_640_500_short.flv";
                     private var _player:VideoElement;

                            public function Example():void
                            {          
                                      
                                      var serialElement = new SerialElement();
                                      serialElement.addChild(new VideoElement
                                                ( new NetLoader
                                                , new URLResource(new URL(REMOTE_PROGRESSIVE))
                                                ))
                                 stage.scaleMode = StageScaleMode.NO_SCALE;
                                 stage.align = StageAlign.TOP_LEFT;


                                 _videoDisplay = new MediaPlayerSprite();
                                 _videoDisplay.element = serialElement;
                                 _videoDisplay.scaleMode = ScaleMode.LETTERBOX;
                                 _videoDisplay.width = 100;  //why do you hate me?
                                 _videoDisplay.height = 100;  //why do you hate me?
                                 addChild(_videoDisplay);
                            }        
                       }
                  }
                  • 6. Re: sizing the MediaPlayerSprite
                    RyanOConnell Level 2

                    Yes, this is how the layout system was designed.  You need to add layout explicitly to each of the children from a composition.  Here is how you would add layout to children from a composition (this specificly gives the video element a scaling layout) :

                     

                    video:VideoElement = new VideoElement( ..  );

                    LayoutUtils.setRelativeLayout(video.metadata, 100, 100);

                     

                     

                    serial:SerialElement = new SerialElement();

                    serial.addChild(video);