Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ppc_michael

Guest
Original poster
Apr 26, 2005
1,498
2
Los Angeles, CA
Hi! I'm building a video player for my site using FLVPlayback and custom UI controls. I have that part down.

As far as behavior for the controls themselves, I want them to be visible as the video buffers, and disappear once the video starts playing. At that point they should come back up when the user rolls the mouse over the video, and disappear once the cursor leaves the video. That part works too.

But here's where I have trouble: when the player is stopped or paused, I want the controls to be up and stay up at all times until playback continues. That's what I've tried to do, but it doesn't work.

Here is what I have:

http://www.glowingpixel.com/av/interface.html

Here is the relevant code. First, the event listeners for stopped, paused, and beginning playback. (My FLVPlayback instance is named "videoPlayer."

Code:
// Event Listeners
videoPlayer.addEventListener(VideoEvent.STOPPED_STATE_ENTERED, showControlsStopped);
videoPlayer.addEventListener(VideoEvent.PAUSED_STATE_ENTERED, showControlsStopped);
videoPlayer.addEventListener(VideoEvent.PLAYING_STATE_ENTERED, hideControlsPlay);

This code fires first, when the video begins to play:
Code:
function hideControlsPlay(evt:Event = null){
	hideControls(evt);
	stage.addEventListener(MouseEvent.MOUSE_OUT, hideControls);
}

This code fires upon pause or stop. I think the problem is removeEventListener is not working maybe?:

Code:
function showControlsStopped(evt:MouseEvent = null){
	showControls(evt);
	stage.removeEventListener(MouseEvent.MOUSE_MOVE, showControls);
	stage.removeEventListener(MouseEvent.MOUSE_OUT, hideControls);
}

And now the actual show and hide functions. My custom UI components are all in a movie clip instance named "controller." So I just slide that up and down.

Code:
// Show player controls
function showControls(evt:Event = null){
	stage.removeEventListener(MouseEvent.MOUSE_MOVE, showControls);
	var controllerShow:Tween = new Tween(controller, "y", Strong.easeOut, controller.y, stage.stageHeight + 13, 1, true);
	trace("Showing controls.\n");
}


// Hide player controls
function hideControls(evt:Event = null){
	stage.addEventListener(MouseEvent.MOUSE_MOVE, showControls);
	var controllerHide:Tween = new Tween(controller, "y", Strong.easeIn, controller.y, stage.stageHeight + 70, 1, true);
	trace("Hiding controls.\n");
}

Any idea why the controls continue to appear/disappear during the stopped or paused modes? Any input is greatly appreciated, because this is driving me crazy.

(Please excuse the cheezy video.)

Thanks!

Edit: Also I just realized that clicking outside of the flash file will cause the controls to come up and stay up until the video is clicked again to reactivate it. Man, it's a real mess.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.