Skip to content

Commit

Permalink
VideoPlayer: added hideRootWhenFullScreen property and throws error i…
Browse files Browse the repository at this point in the history
…f toggleFullScreen() is called when the video player doesn't have access to the stage
  • Loading branch information
joshtynjala committed Apr 13, 2015
1 parent bee3ae8 commit 33c3b69
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions source/feathers/media/VideoPlayer.as
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package feathers.media

import flash.display.Stage;
import flash.display.StageDisplayState;
import flash.errors.IllegalOperationError;
import flash.events.IOErrorEvent;
import flash.events.NetStatusEvent;
import flash.media.SoundTransform;
Expand Down Expand Up @@ -362,6 +363,32 @@ package feathers.media
}
}

/**
* @private
*/
protected var _hideRootWhenFullScreen:Boolean = true;

/**
* Determines if the Starling root display object is hidden when the
* video player switches to full screen mode. By hiding the root display
* object, rendering performance is optimized because Starling skips a
* portion of the display list that is obscured by the video player.
*
* @default true
*/
public function get hideRootWhenFullScreen():Boolean
{
return this._hideRootWhenFullScreen;
}

/**
* @private
*/
public function set hideRootWhenFullScreen(value:Boolean):void
{
this._hideRootWhenFullScreen = value;
}

/**
* @private
*/
Expand Down Expand Up @@ -401,11 +428,16 @@ package feathers.media
*/
public function toggleFullScreen():void
{
if(!this.stage)
{
throw new IllegalOperationError("Cannot enter full screen mode if the video player does not have access to the Starling stage.")
}
var nativeStage:Stage = Starling.current.nativeStage;
var oldIgnoreDisplayListEvents:Boolean = this._ignoreDisplayListEvents;
this._ignoreDisplayListEvents = true;
if(this._isFullScreen)
{
this.root.visible = true;
PopUpManager.removePopUp(this._fullScreenContainer, false);
var childCount:int = this._fullScreenContainer.numChildren;
for(var i:int = 0; i < childCount; i++)
Expand All @@ -417,6 +449,10 @@ package feathers.media
}
else
{
if(this._hideRootWhenFullScreen)
{
this.root.visible = false;
}
nativeStage.displayState = this._fullScreenDisplayState;
if(!this._fullScreenContainer)
{
Expand Down

0 comments on commit 33c3b69

Please sign in to comment.