全屏支持

FLVPlayback 组件的 ActionScript 3.0 版本支持全屏模式,该模式需要 Flash Player 9.0.28.0 或更高版本,还需要针对全屏查看正确设置 HTML。某些预先设计的外观包括一个切换按钮,用于打开和关闭全屏模式。FullScreenButton 图标显示在下图中控制栏的右侧。

控制栏上的全屏图标

仅当将 fullScreenTakeOver 属性设置为 true(默认值)时,才会提供全屏支持。

无论是否有硬件加速支持,都可以提供全屏支持。有关硬件加速支持的信息,请参阅硬件加速

实现对 FLVPlayback 的全屏支持:

  1. 将 FLVPlayback 组件添加到应用程序,然后为其分配一个视频文件。

  2. 为该 FLVPlayback 组件选择一个带有全屏按钮的外观(例如,SkinUnderPlaySeekFullscreen.swf),或者从“组件”面板中的“视频”部分将 FullScreenButton 用户界面组件添加到 FLVPlayback 组件。

  3. 选择“文件”>“发布设置”。

  4. 在“发布设置”对话框中,单击“HTML”选项卡。

  5. 在“HTML”选项卡上,从“模板”弹出菜单中选择“具有全屏支持的 Flash”。

  6. 还是在“HTML”选项卡上,选中“检测 Flash 版本”复选框,然后根据您要使用的 Flash Player 版本,指定 9.0.28 或更高版本。

  7. 选择“格式”选项卡并务必选择 Flash (.swf) 和 HTML (.html) 选项。您可以替换默认文件名。

  8. 单击“发布”,然后单击“确定”。

    作为步骤 7 的替代步骤,可以单击“确定”,然后选择“文件” > “发布预览” > “默认 - (HTML)”以自动在默认浏览器中打开导出的 HTML 文件。否则,可使用您的浏览器打开导出的 HTML 文件以测试全屏选项。

    若要将带全屏支持的 FLVPlayback 组件添加到网页,请打开导出的 HTML 文件,然后复制将 SWF 文件嵌入网页 HTML 文件的代码。这段代码类似于下面的示例:

    //from the <head> section 
     
    <script language="javascript"> AC_FL_RunContent = 0; </script>  
    <script language="javascript"> DetectFlashVer = 0; </script>  
    <script src="AC_RunActiveContent.js" language="javascript"></script> 
    <script language="JavaScript" type="text/javascript">  
    <!--  
    // -----------------------------------------------------------------------------  
    // Globals  
    // Major version of Flash required  
    var requiredMajorVersion = 9;  
    // Minor version of Flash required  
    var requiredMinorVersion = 0;  
    // Revision of Flash required  
    var requiredRevision = 28;  
    // -----------------------------------------------------------------------------  
    // -->  
    </script>  
     
    //and from the <body> section 
     
    <script language="JavaScript" type="text/javascript">  
    <!--  
    if (AC_FL_RunContent == 0 || DetectFlashVer == 0) {  
        alert("This page requires AC_RunActiveContent.js.");  
    } else {  
        var hasRightVersion = DetectFlashVer(requiredMajorVersion, 
            requiredMinorVersion, requiredRevision);  
        if(hasRightVersion) { // if we&apos;ve detected an acceptable version  
            // embed the Flash movie  
            AC_FL_RunContent(  
                &apos;codebase&apos;, &apos;http://download.macromedia.com/pub/ 
                    shockwave/cabs/flash/swflash.cab#version=9,0,28,0&apos;,  
                &apos;width&apos;, &apos;550&apos;,  
                &apos;height&apos;, &apos;400&apos;, 
                &apos;src&apos;, &apos;fullscreen&apos;,  
                &apos;quality&apos;, &apos;high&apos;,  
                &apos;pluginspage&apos;, &apos;http://www.macromedia.com/go/ 
                    getflashplayer&apos;,  
                &apos;align&apos;, &apos;middle&apos;,  
                &apos;play&apos;, &apos;true&apos;,  
                &apos;loop&apos;, &apos;true&apos;,  
                &apos;scale&apos;, &apos;showall&apos;,  
                &apos;wmode&apos;, &apos;window&apos;,  
                &apos;devicefont&apos;, &apos;false&apos;,  
                &apos;id&apos;, &apos;fullscreen&apos;,  
                &apos;bgcolor&apos;, &apos;#ffffff&apos;,  
                &apos;name&apos;, &apos;fullscreen&apos;,  
                &apos;menu&apos;, &apos;true&apos;, 
                &apos;allowScriptAccess&apos;,&apos;sameDomain&apos;, 
                &apos;allowFullScreen&apos;,&apos;true&apos;,  
                &apos;movie&apos;, &apos;fullscreen&apos;,  
                &apos;salign&apos;, &apos;&apos; ); //end AC code  
        } else { // Flash is too old or we can&apos;t detect the plug-in.  
            var alternateContent = &apos;Alternative HTML content should be placed 
                    here.&apos;  
                + &apos;This content requires Adobe Flash Player.&apos;  
                + &apos;<a href=http://www.macromedia.com/go/getflash/>Get Flash</a> 
                        &apos;;  
            document.write(alternateContent); // Insert non-Flash content.  
        }  
    }  
    // -->  
    </script>  
    <noscript>  
        // Provide alternative content for browsers that do not support scripting  
        // or for those that have scripting disabled.  
        Alternative HTML content should be placed here. This content requires Adobe Flash Player.  
        <a href="http://www.macromedia.com/go/getflash/">Get Flash</a>  
    </noscript>

    另一种方法是,可将导出的 HTML 文件用作网页的模板,然后在其中添加其它内容。但是,如果您采用此方法,请更改 HTML 文件的名称,以免以后再次从 Flash 导出 FLVPlayback HTML 文件时,将其意外覆盖。

    在任何情况下,都必须将 AC_RunActiveContent.js 文件也上载到 Web 服务器上,该 js 文件与 HTML 文件导出在同一个目录下。

    ActionScript 对全屏模式的支持包括 fullScreenBackgroundColorfullScreenSkinDelayfullScreenTakeOver 属性,以及 enterFullScreenDisplayState() 方法。有关这些 ActionScript 元素的信息,请参阅 Adobe ActionScript 3.0 Reference for the Adobe Flash Platform

使用 enterFullScreenDisplayState()

您还可以通过调用 enterFullScreenDisplayState() ActionScript 方法来调用全屏模式,如下例所示。

function handleClick(e:MouseEvent):void { 
    myFLVPlybk.enterFullScreenDisplayState(); 
} 
myButton.addEventListener(MouseEvent.CLICK, handleClick);

此例中,全屏模式不是 通过单击 FLVPlayback 外观上的全屏切换按钮调用的,而是通过单击网页创建者包含来调用全屏模式的按钮 (MyButton) 调用的。单击该按钮将触发 handleClick 事件处理函数,该处理函数调用 enterFullScreen DisplayState() 方法。

enterFullScreenDisplayState() 方法将 Stage.displayState 属性设置为 StageDisplayState.FULL_SCREEN,因此具有与 displayState 属性相同的限制。有关 enterFullScreenDisplayState() 方法和 Stage.displayState 属性,请参阅 Adobe ActionScript 3.0 Reference for the Adobe Flash Platform

硬件加速

Flash Player 9.0.115.0 及更高版本提供一些代码,这些代码借助可用的视频硬件来提高 FLVPlayback 在全屏模式下播放 FLV 文件时的性能和保真度。如果前提条件满足,并且 fullScreenTakeOver 属性设置为 true,则 Flash Player 使用硬件加速来缩放视频文件,而不是通过软件进行缩放。如果 FLVPlayback 组件在早期版本的 Flash Player 中运行,或者硬件加速的前提条件不存在,则 Flash Player 将像以前一样自己放大视频文件。

若要利用硬件加速提供全屏支持,计算机上必须有兼容 DirectX 7 的显卡,4 MB 或更多 VRAM(视频 RAM)。Windows 2000 或 Mac OS X 10.2 以及这两种操作系统的更高版本提供此硬件支持。Direct X® 提供的 API 构成了软件和视频硬件之间的接口,用于加速三维和二维图形,以及执行其它功能。

为了利用硬件加速模式,您还必须通过以下方法之一调用全屏模式:

  • 使用 FLVPlayback 外观上的全屏切换按钮

  • 使用 FullScreenButton 视频控件

  • 使用 ActionScript enterFullScreenDisplayState() 方法。有关详细信息,请参阅使用 enterFullScreenDisplayState()

    如果通过将 Stage.displayState 属性设置为 StageDisplayState.FULLSCREEN 来调用全屏模式,则 FLVPlayback 不使用硬件加速,即使视频硬件和内存符合要求也是如此。

    使用硬件加速提供全屏支持的一个结果是,FLVPlayback 外观将与视频播放器和视频文件一起缩放。下图显示了采用硬件加速的全屏模式对 FLVPlayback 外观的影响,此处以完全分辨率显示一个细节。

    1600 x 1200 显示器使用全屏模式显示 320x240 像素的视频
    1600 x 1200 显示器使用全屏模式显示 320x240 像素的视频

    此图显示了在 1600 x 1200 监视器上对某个视频文件(默认的 FLVPlayback 尺寸,即宽 320,高 240)使用全屏模式的结果。FLV 文件的尺寸越小,或者监视器越大,外观的扭曲效果就越明显。相反,FLV 文件越大,或者监视器越小,扭曲效果就越不明显。例如,从 640 x 480 更改为 1600 x 1200 还是会增大外观的大小,但是看上去扭曲程度更小。

    您可以设置 skinScaleMaximum 属性以限制 FLVPlayback 外观的缩放。默认值为 4.0,即 400%。但是,如果限制外观的缩放,则需要结合硬件和软件才能缩放 FLV,对于以高比特率编码的大尺寸 FLV 来说,性能将受影响。如果视频很大(例如,640 像素或更宽,480 像素或更高),则不应将 skinScaleMaximum 设置为较小的值,因为这可能会导致大显示器出现较大的性能问题。skinScaleMaximum 属性可用于控制较大外观的性能、质量和外观之间的平衡。

退出全屏模式

若要退出全屏模式,请再次单击全屏按钮,或按 Esc 键。

设置以下属性并调用以下方法可产生使 FLVPLayback 组件退出全屏模式的布局更改:heightregistrationHeightregistrationWidthregistrationXregistrationYscaleXscaleYwidthxysetScale()setSize()

如果设置了 alignscaleMode 属性,FLVPlayback 将把这两个属性设置为 centermaintainAspectRatio,直到退出全屏模式为止。

在使用全屏时,如果将 fullScreenTakeOver 属性从 true 更改为 false,则硬件加速模式也会使 Flash 退出全屏模式。