As3 full screen video mode

I created a video player, but you need to add a button that will put the video into full screen view when clicked. I don't want to scale everything on stage - just video. I can't seem to find how to do this - I thought it would be easy.

+2


source to share


5 answers


See if this works:



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


source


My understanding is that you can set the entire stage to full screen rather than elements, since you are effectively scaling the scene object at the root of the display tree. The best way to achieve the effect you are looking for is to organize / hide / show any objects you do not want to see in the FullScreenEvent.FULL_SCREEN event handler.

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



Also, the relevant maze from the Stage docs, displayState section :

The scaling behavior of a movie in full screen mode is determined by the scaleMode setting (set using the Stage.scaleMode property or the SWF file insert tag settings in the HTML file). If the scaleMode property is set to noScale, when the application enters full screen mode, the scene width and height properties are updated, as well as the Stage resize event.

+1


source


More recently this issue came up and it worked like a charm. Therefore, putting it here if it helps someone.

Flex client code:

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 )
    }
}

      

+1


source


If the elements in the scene are being scaled, it sounds like you are using the fullScreenRect property rather than just instructing the scene object to go full screen.

Amarghosh has the right approach, but it can be made more flexible by adding a listener:

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

      

0


source


Entering full screen mode

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

      

To exit full screen mode

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

      

Note. You can also press escape.

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

0


source







All Articles