Investigation of CircleCube Video Player (Day 7)

Now we are at point where to add a function: when the player is in playing state, then start the timer, to hide the control panel.


version b.4

For now, the logic is: if the cursor is outside the vcr area, then mouseStill will increase, and until it reaches mouseStillMax(=3), then the vcr hides. And this Timer will be triggered in showVCR(), but now it is commented. And we will trigger it when play|pause the video, so change the playDown() to:

public function playDown($e:MouseEvent=null):void
{
	...
	switch ($cs) 
	{
		case "ready":
		{
			...
			mouseStill = 0;
			mouseTimer.start();
			break;
		}
		case "playing":
		{
			...	
			mouseStill = 0;
			mouseTimer.stop();
			break;
		}
		case "paused":
		{
			...
			mouseStill = 0;
			mouseTimer.start();
			break;
		}
		case "complete":
		{
			...
			mouseStill = 0;
			mouseTimer.start();
			break;
		}
		default:
		{
			trace("ERROR: " + currentStatus);
		}
	}
	return;
}


And add hidePlayOverlay() call into mouseStatus() to hideplayOverlay together:

public function mouseStatus($e:TimerEvent):void
{
	if (mouseY < vcr.y || mouseY > vcr.height + vcr.y) 
	{
		mouseStill++;
	}
	if (mouseStill > mouseStillMax) 
	{
		mouseStill = 0;
		hideVCR();
		hidePlayOverlay();
	}
	return;
}


And, we should remember we have not updated videoComplete(), we should show vcr and playOverlay when video finished, and clear the timer that would hide them:

public function videoComplete():void
{
	ns.pause();
	videoTimer.stop();
	currentStatus = "complete";
	vcr.bar.bg.width = 0;
	vcr.bar.loadbar.width = 0;
	vcr.bar.playbar.width = 0;
	vcr.bar.scrub.x = 0;
	
	playOverlay.icon.gotoAndStop("playing");
	
	showPlayOverlay();
	showVCR();
	mouseStill = 0;  
	mouseTimer.stop();
	
	clearVideoStatus();
	
	vid.setChildIndex(video, vid.numChildren - 2);
	return;
}


Now, talk about the condition that increase mouseStill, it is reasonable to keep the current logic, because you may operate on theVCR, then it should not disappear.


But you may notice that the delay of hiding vcr is not even, we need reset mouseStill to 0 when togglevcr to show:

public function toggleVCR($e:MouseEvent=null):void
{
	if (vcr.timeCurrent.timeDisplay.visible)
	{
		hideVCR();
		hidePlayOverlay();
	}
	else
	{
		showVCR();
		showPlayOverlay();
		mouseStill = 0;
	}
}


And, for securing the operation, we should unlock the control after it shows 100%, so change showVCR():

public function showVCR($e:MouseEvent=null):void
{
	if (!vcr.timeCurrent.timeDisplay.visible) 
	{
		vcr.mouseChildren = true;
		
		com.greensock.TweenNano.to(
									vcr, 
									0.4, 
									{
										"alpha":fadeInAlpha, 
										"ease":com.greensock.easing.Quad.easeOut
									}
								   );
								   
		vcr.timeCurrent.timeDisplay.visible = true;
		vcr.timeTotal.timeDisplay.visible = true;
	}
	return;
}

to:

public function showVCR($e:MouseEvent=null):void
{
	if (!vcr.timeCurrent.timeDisplay.visible) 
	{		
		com.greensock.TweenNano.to(
									vcr, 
									0.4, 
									{
										"alpha":fadeInAlpha, 
										"ease":com.greensock.easing.Quad.easeOut,
										"onComplete": function(){vcr.mouseChildren = true;}
									}
								   );
								   
		vcr.timeCurrent.timeDisplay.visible = true;
		vcr.timeTotal.timeDisplay.visible = true;
	}
	return;
}


change showPlayOverlay():

public function showPlayOverlay():void
{
	playOverlay.mouseEnabled = true;
	
	com.greensock.TweenNano.to(
								playOverlay, 
								0.2, 
								{
									"alpha":0.75, 
									"scaleX":playOverlay.sXY, 
									"scaleY":playOverlay.sXY, 
									"ease":com.greensock.easing.Back.easeOut, 
									"overwrite":false
								}
							   );
	return;
}

to:

public function showPlayOverlay():void
{
	com.greensock.TweenNano.to(
								playOverlay, 
								0.2, 
								{
									"alpha":0.75, 
									"scaleX":playOverlay.sXY, 
									"scaleY":playOverlay.sXY, 
									"ease":com.greensock.easing.Back.easeOut, 
									"onComplete": function(){playOverlay.mouseEnabled = true;},
									"overwrite":false
								}
							   );
	return;
}


Inside onMetaData() and onXMPData(), replace call to playerLayout(), with videoLayout().

public function onMetaData($obj:Object):void
{
	if (duration == -1 || !pl_duration) 
	{
		duration = Number($obj["duration"]);
		trace("onMetaData duration:", duration);
		pl_duration = true;
		videoLayout();
	}
	return;
}

public function onXMPData($obj:Object):void
{
	if (duration == -1 || !pl_duration) 
	{
		duration = Number($obj["duration"]);
		trace("onXMPdata duration:", duration);
		pl_duration = true;
		videoLayout();
	}
	return;
}


and remove playerLayout(), since it just callvideoLayout():

public function playerLayout():void
{
	videoLayout();
	return;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值