1 Reply Latest reply on Sep 16, 2013 9:44 AM by ymichel

    VAST / Video cropped

    ymichel Level 1

      Hi,

       

      When I load a VAST resource via the OSMF VAST library, my ad is cropped and I can't apply the LETTERBOX scale mode. Here is a sample code :

       

       

      package
      {
          import flash.display.*;
          import flash.events.*;
          import flash.utils.*;
      
          import org.osmf.containers.*;
          import org.osmf.media.*;
          import org.osmf.elements.*;
          import org.osmf.traits.*;
          import org.osmf.net.*;
          import org.osmf.events.*;
          import org.osmf.layout.*;
      
          import org.osmf.vast.loader.*;
          import org.osmf.vast.media.*;
      
          public class Application extends Sprite
          {
              private var vastLoader:VASTLoader;
              private var vastLoadTrait:VASTLoadTrait;
      
              private var mediaContainer:MediaContainer;
              private var mediaPlayer:MediaPlayer;
              private var mediaElement:MediaElement;
      
              public function Application()
              {
                  stage.align = StageAlign.TOP_LEFT;
                  stage.scaleMode = StageScaleMode.NO_SCALE;
                  stage.color = 0x000000;
      
                  prepare();
      
                  load('http://ads.stickyadstv.com/www/delivery/swfIndex.php?zoneId=7369&protocolVersion=2.0&reqType=AdsSetup');
              }
      
              private function prepare():void
              {
                  mediaContainer = new MediaContainer();
                  addChild(mediaContainer);
      
                  mediaPlayer = new MediaPlayer();
                  mediaPlayer.autoPlay = true;
                  mediaPlayer.volume = 1;
      
                  mediaContainer.layoutMetadata.width = stage.stageWidth;
                  mediaContainer.layoutMetadata.height = stage.stageHeight;
                  mediaContainer.layoutMetadata.scaleMode = ScaleMode.LETTERBOX;
              }
      
              private function load(url:String):void
              {
                  vastLoader = new VASTLoader();
                  vastLoadTrait = new VASTLoadTrait(vastLoader, new URLResource(url));
      
                  vastLoader.addEventListener(LoaderEvent.LOAD_STATE_CHANGE, onVASTLoadStateChange);
                  vastLoader.load(vastLoadTrait);
              }
      
              private function onVASTLoadStateChange(event:LoaderEvent):void
              {
                  if (event.newState == LoadState.READY)
                  {
                      // fetches linear ads only
                      var vastMediaGenerator:VASTMediaGenerator = new VASTMediaGenerator();
                      var vastElements:Vector.<MediaElement> = vastMediaGenerator.createMediaElements(vastLoadTrait.vastDocument, VASTMediaGenerator.PLACEMENT_LINEAR);
      
                      // considers the first element is the ad
                      if (vastElements && vastElements.length > 0)
                      {
                          var vastElement:MediaElement = vastElements[0];
      
                          // tries to apply LETTERBOX scale mode
                          var layoutMetadata:LayoutMetadata = vastElement.getMetadata(LayoutMetadata.LAYOUT_NAMESPACE) as LayoutMetadata || new LayoutMetadata();
                          layoutMetadata.scaleMode = ScaleMode.LETTERBOX;
                          vastElement.addMetadata(LayoutMetadata.LAYOUT_NAMESPACE, layoutMetadata);
      
                          // plays the ad
                          mediaContainer.addMediaElement(vastElement);
                          mediaPlayer.media = vastElement;
                      }
                  }
              }
          }
      }
      
      

       

      Even if I add a layout metadata on my media element (the ad), the scale mode never changes. Do I forget something ?

        • 1. Re: VAST / Video cropped
          ymichel Level 1

          I can apply the correct scale-mode when I directly use the creative mp4 and core OSMF components : DefaultMediaFactory, MediaContainer and MediaPlayer. I'm maybe wrong but the issue seems to be located in the OSMF VAST Library.