【问题标题】:as3 video full screen modeas3视频全屏模式
【发布时间】:2015-11-14 03:22:42
【问题描述】:

我创建了一个视频播放器,但需要添加一个按钮,当点击该按钮时,视频会进入全屏观看模式。我不想缩放舞台上的所有东西——只是视频。我似乎找不到如何做到这一点 - 我认为这很容易。

【问题讨论】:

    标签: actionscript-3 video flv fullscreen


    【解决方案1】:

    看看这是否有效:

    stage.displayState = StageDisplayState.FULL_SCREEN;
    videoPlayer.x = 0;
    videoPlayer.y = 0;
    //save the width and height in temp vars 
    //for restoring them later.
    videoPlayer.width = stage.fullScreenWidth;
    videoPlayer.height = stage.fullScreenHeight;
    

    【讨论】:

      【解决方案2】:

      我的理解是,您只能将整个舞台设置为全屏,而不是有选择地设置元素,因为您正在有效地放大显示树根部的舞台对象。实现您正在寻找的效果的最佳方法是安排/隐藏/显示您不希望在 FullScreenEvent.FULL_SCREEN 事件处理程序中可见的任何对象。

      http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/events/FullScreenEvent.html

      另外,来自 Stage 文档的相关花絮,displayState section

      电影在全屏模式下的缩放行为由 scaleMode 设置确定(使用 Stage.scaleMode 属性或 HTML 文件中的 SWF 文件的嵌入标签设置进行设置)。如果在应用程序转换到全屏模式时将 scaleMode 属性设置为 noScale,则会更新 Stage 的宽度和高度属性,并且 Stage 会发生 resize 事件。

      【讨论】:

        【解决方案3】:

        最近遇到了这个问题,这很有魅力。所以把它放在这里以防它对任何人有帮助。

        Flex 客户端代码:

        private function startFullScreen(event:MouseEvent):void
        {    
            videoHolder.removeChild(vid);  //videoHolder is an spark VideoDisplay  
                                               Component
            this.stage.addChild(vid);           
            this.stage.displayState = StageDisplayState.FULL_SCREEN;
            oldWidth = vid.width;         //store old values required while going back
            oldHeight = vid.height;
            vid.width = this.stage.width;
            vid.height = this.stage.height;
            this.stage.addEventListener(FullScreenEvent.FULL_SCREEN,fullScreenHandler);
        }
        } 
        
        
        /*      handler for Fullscreen      */
        private function fullScreenHandler(event:FullScreenEvent):void
        {
            //This function is called when user presses Esc key 
            //on returning to normal state, add the video back  
        
            if(!event.fullScreen)
            {               
                this.stage.removeChild(vid);
                videoHolder.addChild(vid);
                vid.width = oldWidth;
                vid.height = oldHeight;
                this.stage.removeEventListener(FullScreenEvent.FULL_SCREEN,fullScreenHandler )
            }
        }
        

        【讨论】:

          【解决方案4】:

          如果舞台上的元素正在缩放,听起来好像您正在使用 fullScreenRect 属性,而不是简单地指示舞台对象进入全屏模式。

          Amarghosh 有正确的方法,但可以通过附加监听器使其更加灵活:

          stage.addEventListener(Event.RESIZE, _onStageResize, false, 0, true);
          stage.displayState = StageDisplayState.FULL_SCREEN;
          
          private function _onStageResize(event:Event):void
          {
              if(stage.displayState == StageDisplayState.FULL_SCREEN)
              {
                  // Proportionally resize your video to the stage's new dimensions
                  // i.e. set its height and width such that the aspect ratio is not distorted
              }
              else
              {
                  // Restore the normal layout of your elements
              }
          }
          

          【讨论】:

            【解决方案5】:

            进入全屏模式

            var fullScreenButton:Button = new Button();
            ...
            addChild(fullScreenButton); 
            fullScreenButton.addEventListener(MouseEvent.CLICK, fullScreenButtonHandler);
            ...
            private function fullScreenButtonHandler(event:MouseEvent) 
            {  
                var screenRectangle:Rectangle = new Rectangle(video.x, video.y, video.width, video.height); 
                stage.fullScreenSourceRect = screenRectangle; 
                stage.displayState = StageDisplayState.FULL_SCREEN;  
            }
            

            离开全屏模式

            ...
            stage.displayState = StageDisplayState.NORMAL;
            ...
            

            注意:你也可以按escape。

            来源:http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS44B1892B-1668-4a80-8431-6BA0F1947766.html

            【讨论】:

              猜你喜欢
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 2010-10-19
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 2019-09-01
              • 2017-01-19
              相关资源
              最近更新 更多