Skip navigation
Currently Being Moderated

osmf scale with MediaPlayerSprite

Aug 22, 2011 2:40 AM

I am working through the example given with the OSMF download and it says :

 

For visual content, determining how it is sized and scaled is often integral to a successful viewing experience. Because this functionality can be so important, OSMF provides access to scale modes within MediaPlayerSprite.
To control the content scale mode, set MediaPlayerSprite.scaleMode with one of the following constants:
LETTERBOX, NONE,STRETCH, ZOOM

 

package
{
    import flash.display.Sprite;
    import org.osmf.media.MediaPlayerSprite;
    import org.osmf.display.ScaleMode;
    import org.osmf.media.URLResource;
    [SWF(width = "640",height = "352")]
   
    public class HelloWorld extends Sprite
    {
        public function HelloWorld()
        {
            // Create the container class that displays the media.
            var sprite:MediaPlayerSprite = new MediaPlayerSprite();
            addChild(sprite);
            sprite.scaleMode=ScaleMode.LETTERBOX
            // Assign the resource to play. This generates the appropriate
            // MediaElement and passes it to the MediaPlayer. Because the MediaPlayer
            // autoPlay property defaults to true, playback begins immediately.
            sprite.resource = new URLResource("video/myVideo.f4v");
            ;
        }
    }
}

 

This does not resize the MediaPlayerSprite on stage. Can someone shed some light on this for me?

 
Replies
  • Currently Being Moderated
    Aug 22, 2011 7:00 AM   in reply to TezS56

    SacleMode takes effect only when you set the size of the MediaPlayerSprite. You haven't set the size so the media will play in its native size. (By the way letterbox is the default so you don't need to set it explicitly.)

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 23, 2011 2:30 AM   in reply to TezS56

    Well to set the size you'd do:

    sprite.width = n;
    sprite.height = n;
    

    If you set the shape of the MediaPlayerSprite to for example square and set the scaleMode to stretch you can see what these settings do.

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 23, 2011 3:35 AM   in reply to TezS56

    If you want to set the MediaPlayerSprite to the size of the SWF you can do so by setting the width/height to stage.stageWidth/stage.stageHeight.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points