1 Reply Latest reply on Aug 11, 2011 4:14 PM by MarceloReborn

    How to resize a video player?

    MarceloReborn Level 1

      I'm building a player with two switchable sizes, changed by the user, but I'm not having results on that.

       

      That's my setupPlayer function, which works fine:

       

      function setupPlayer():void

      {

                 layout.width  = _playerWidth;
                  layout.height = _playerHeight;
                  layout.layoutMode = LayoutMode.HORIZONTAL
                  layout.horizontalAlign = HorizontalAlign.CENTER;
                  layout.verticalAlign = VerticalAlign.TOP;
                  layout.scaleMode = ScaleMode.LETTERBOX;
                 
                  videoElement.addMetadata(LayoutMetadata.LAYOUT_NAMESPACE, layout);
                  videoElement.smoothing = true;
                             
                  mediaPlayer.loop = false;
                  mediaPlayer.autoPlay = _autoPlay;             
                  mediaContainer.addMediaElement(videoElement);
                  videoCanvas.addChild(mediaContainer);  

       

                     .... // more code //

       

      Then, I feed the player and it starts to play normally, it's when I try to resize it. (I did read somewhere that I needed to change the LayoutMetadata):

       

      public function resize(width:Number, height:Number):void
      {
                  // none of this worked
                  //mediaContainer.width = 1200;
                  //mediaContainer.height = 2000;
                  //mediaContainer.layout(1200, 2000, true);

                 

                  // neither this
                  var layout:LayoutMetadata = new LayoutMetadata();
                  layout.width  = 1500;
                  layout.height = 1500;
                  layout.layoutMode = LayoutMode.HORIZONTAL
                  layout.horizontalAlign = HorizontalAlign.CENTER;
                  layout.verticalAlign = VerticalAlign.TOP;
                  layout.scaleMode = ScaleMode.STRETCH;
                 
                  videoElement.removeMetadata(LayoutMetadata.LAYOUT_NAMESPACE)
                  videoElement.addMetadata(LayoutMetadata.LAYOUT_NAMESPACE, layout);
      }

       

      Someone can point where my error is?

      Thanks!

        • 1. Re: How to resize a video player?
          MarceloReborn Level 1

          I figured out. Maybe this can be useful to someone:

           

          public function resize(width:Number, height:Number):void
          {
                      mediaContainer
          .width  = width;
                      mediaContainer
          .height = height;

                     
          var layout:LayoutMetadata = new LayoutMetadata();
                      layout
          .width  = width;
                      layout
          .height = height;
                      layout
          .layoutMode = LayoutMode.HORIZONTAL;
                      layout
          .horizontalAlign = HorizontalAlign.CENTER;
                      layout
          .verticalAlign = VerticalAlign.TOP;
                      layout
          .scaleMode = ScaleMode.STRETCH;

                      videoElement
          .removeMetadata(LayoutMetadata.LAYOUT_NAMESPACE);
                      videoElement
          .addMetadata(LayoutMetadata.LAYOUT_NAMESPACE, layout);
          }