问题
I am playing a flv video using the videoplayer class of flex. (all the properties of it are being set at runtime)
I want to make the video fullscreen without clicking on the fullscreen button i.e. through programming.
Is it possible. If yes then how can I do this.?
回答1:
Dispatch click event from the fullScreenButton of VideoPlayer.
yourplayer.fullScreenButton.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
回答2:
Use the displayState property of the stage. You can access the stage as a variable on the Application class. So, conceptually, do this:
FlexGlobals.topLevelApplication.stage.displayState = StageDisplayState.FULL_SCREEN
run this code in an applicationComplete event handler on the main application tag to put your app into full screen mode after it is finished loading.
回答3:
You can remove the VideoDisplay from it's parent and then add it to the stage at full width & height. Reverse the process when exiting full screen.
protected function fullScreenBtn_clickHandler(event:MouseEvent):void
{
videoContainer.removeChild(videoDisplay)
this.stage.addChild(videoDisplay);
this.stage.displayState = StageDisplayState.FULL_SCREEN;
videoDisplay.width = stage.width;
videoDisplay.height = stage.height;
this.stage.addEventListener(FullScreenEvent.FULL_SCREEN, fullScreenHandler);
}
protected function fullScreenHandler(event:FullScreenEvent):void
{
if(!event.fullScreen)
{
this.stage.removeChild(videoDisplay);
this.videoContainer.addChild(videoDisplay);
videoDisplay.percentHeight = videoDisplay.percentWidth = 100;
this.stage.removeEventListener(FullScreenEvent.FULL_SCREEN, fullScreenHandler);
}
}
来源:https://stackoverflow.com/questions/7107692/how-do-i-make-a-video-full-screen-using-actionscript-in-flex-desktop-application