如何使基于 Netstream 的 Actionscript 视频播放器自动调整大小以匹配父级大小?

发布于 2024-10-21 02:29:43 字数 513 浏览 1 评论 0原文

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

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

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

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

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

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

预先感谢您的帮助。

(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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

等待圉鍢 2024-10-28 02:29:43

尝试这样的事情

// 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;
}

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;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文