0

(我是 Actionscript 的新手,如果这是一个简单的问题,我很抱歉。)

我在 Actionscript 中做一个媒体播放器,我有以下类层次结构:

  • 主类,扩展 Sprite,并包含
    • VideoPlayer 类,扩展 Sprite,包含一个 Video 对象并使用 Netstream 加载视频

视频播放器将嵌入到具有不同大小容器的不同应用程序中。有没有办法让视频播放器根据父容器的大小(在 html/swfobject 中定义)调整大小?

我在 Main 类上使用了“scaleMode”属性,并设法使 flash 对象根据容器重新缩放,但视频始终具有相同的大小。

此外,我使用视频剪辑的元数据手动和自动更改了 Video 对象的“宽度”和“高度”属性,并且视频尺寸似乎是错误的 - 我有一个 320x240 的 swf 对象,当我更改了视频大小与 swfobject 大小相匹配,它呈现的尺寸远小于 320x240。

在此先感谢您的帮助。

4

1 回答 1

0

尝试这样的事情

// 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;
}
于 2012-05-18T14:03:03.087 回答