esc from fullscreen using video in full screen min

2019-08-18 19:31发布

问题:

I have an application intended to run in full screen mode. In order to prevent it from getting out of full screen I did:

protected function windowedapplication_preinitializeHandler(event:FlexEvent):void
{
     nativeWindow.stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
     nativeWindow.stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
}

protected function onKeyDown(event:KeyboardEvent):void
{
   if (event.keyCode == 27)
   {
      event.preventDefault();
    }
}

That prevents the app getting out of full screen but my app has a video player with an option to go full-screen with the video and at that point when i press esc the whole app and the video come to smaller size.

Thanks in advance!

回答1:

You couldn't prevent ESC key to exit from full screen mode. This is security issue.



回答2:

You can listen for the FullScreenEvent and set the stage.displayState to return back to full screen when FullScreenEvent.FULL_SCREEN is dispatched.

This way, the app will change back to full screen even when the user clicks the full screen button to exit full screen mode in the video player.

private function onApplicationComplete(event:Event):void{

      stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
      stage.addEventListener(FullScreenEvent.FULL_SCREEN, onFullScreenChange);

}

private function onFullScreenChange(event:FullScreenEvent):void{

      stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
}