0
votes

(I am new to Actionscript and I am sorry if this is a simple question.)

I am doing a media player in Actionscript and I have the following class hierarchy:

  • Main class, extends Sprite, and contains
    • VideoPlayer class, extends Sprite, contains a Video object and loads the videos using Netstream

The video player will be embedded in different applications with containers with different sizes. Is there a way to make the video player to resize according to the size of the parent container (as defined in the html / swfobject)?

I played with the "scaleMode" properties on the Main class and I managed to make the flash object to rescale according to the container, but the video has always the same size.

Additionally, I changed the "width" and "height" properties of the Video object, both manually and automatically using the metadata of the video clip, and the video dimensions seem to be wrong - I have a swfobject with 320x240 and when I changed the size of the video to match the swfobject size, it rendered much smaller than 320x240.

Thanks in advance for the help.

1
Have you tried setting the height and width of the Video object in a ResizeEvent.RESIZE handler? The width and height properties should be the way to go.merv
Not yet. I'm setting the player width / height when the netstream buffer is full. When I do this I can see the size of the player changing on the screen. What is weird is that I have a div with 320x240 (I checked with Firebug and it's correctly rendered with this size) with the flash object inside and when I set the video player dimensions to 320x240 it results in much smaller window that it should. Resuming I have a div 320x240 ok -> swf 320x240 ok -> video "child" 320x240 nok / smaller than it should. The video that I am playing is 320x240.luis
When you say 'video "child" 320x240 nok', do you mean that it is returning the right dimensions when you trace it, but when it renders it is smaller than 320x240? Also, I've used the resize handler to deal with sizing swf's and Video objects because browser zooming tends to do really inconsistent things across different browsers. You might want to also try tracing some of the scaling properties.merv

1 Answers

0
votes

try something like this

// get the video aspect ratio
// 1.33 (4/3)  | 640 x 480
// 1.77 (16/9) | 854 x 480
//trace(_video_width / _video_height);
videoAspectRatio    = _video_width / _video_height;

// check if video is larger than stage
// check which is larger: height or width
// set video size as the largers of height or width

// if video is a 4/3 aspect ratio
if( videoAspectRatio  < 1.4)
{
    myVideo.width   = _stageWidth / videoAspectRatio;   
    myVideo.height  = myVideo.width / videoAspectRatio;

    // if movie is still to small to the stage make it bigger
    if(myVideo.height < _stageHeight)
    {
            myVideo.width = myVideo.width * (_stageHeight/myVideo.height);
            myVideo.height = _stageHeight
    }
}
else
{
    myVideo.width   = _stageWidth;
    myVideo.height  = _stageWidth / videoAspectRatio;
}