jspooner
jspooner

Reputation: 11315

set video size in OSMF

OSMV is very thick so so I'm trying to put a series of minimalist tutorials and again I'm stuck with something that should be dead simple.

I have a VideoElement that I added to a MediaPlayer. Now now do I set the size of the video?

I'd like to just set the size on the mediaPlayer or MediaElement and not include 20 layout classes like the OSMF examples.

private function handle_elementLoaded(e:MediaFactoryEvent):void
{
     mediaPlayer = new MediaPlayer(e.mediaElement); 
         mediaPlayer.addEventListener(MediaPlayerStateChangeEvent.MEDIA_PLAYER_STATE_CHANGE, handle_stateChange);
          }


          private function handle_stateChange(e:MediaPlayerStateChangeEvent):void
          {
               trace("handle_stateChange",e.state);
               if (e.state == MediaPlayerState.READY)
                      {
                    addChild(mediaPlayer.displayObject);
                      } 
          }

Upvotes: 0

Views: 2809

Answers (1)

user296970
user296970

Reputation: 66

This is relatively simple. We've introduced the MediaPlayerSprite to take care of most of the headache for you:

public function MediaPlayerSpriteSample() {

//Neccesary to prevent the MPS from scaling via ScaleX and ScaleY.

stage.scaleMode = StageScaleMode.NO_SCALE;

stage.align = StageAlign.TOP_LEFT;

// Create the container class that displays the media.

mps = new MediaPlayerSprite();

addChild(mps);

stage.addEventListener(Event.RESIZE, onResize);

mps.resource = new URLResource(REMOTE_AKAMAI_STREAM);

//Update the MPS to the initial size.

onResize();

}

private function onResize(event:Event = null):void

{

mps.width = stage.stageWidth;

mps.height = stage.stageHeight;

}

Upvotes: 5

Related Questions