ActionScript 3 Seekbar Problem

Hi guys,

I am relatively new to AS but have experience of JS. I have created a progress seeker/Scrubber on my YouTube Chromeless Player which works fine but now I have to make the scrubber handle move on its own as the video progresses. Again this wasn’t too much of a problem but now that I have implemented it and started testing it just sin’t performing as I’d like it to. Here are my functions below:



function ProgDrag(event:Event):void
{
	clearInterval(my_interval);     //stop updating the scrubber position
	player.pauseVideo();              // pause video while user slides progress bar
	prog_sliding = true;
	mcPanel.prog_slider.prog_handle.buttonMode = true;
	mcPanel.prog_slider.prog_handle.useHandCursor = true;
	mcPanel.prog_slider.prog_handle.startDrag(false,prog_obj);   //drag progress bar
}
function ProgDrop(event:Event):void
{
	if (prog_sliding)
	{
		mcPanel.prog_slider.prog_handle.stopDrag();  
		var ratio:Number = Math.round((mcPanel.prog_slider.prog_handle.x+1)*player.getDuration()/(mcPanel.prog_slider.prog_range.width));
		player.seekTo(ratio, true);         // seek to the new calculated position
		player.playVideo();                   //resume playback
		prog_sliding = false;
		setInterval(UpdateProgress, 200)     // this function gets the current time and updates the   new scrubber position
	}
}



Basically the Problem is that when the user drags the video seeker to a new position (Sometimes not all the time), the cursor seems to want to stay where it is and even struggles in the opposite direction against the mouse drag. Is this a particular issue with doing this in flash? Can anyone help me to eliminate it, it is annoying more than anything but I don’t have the experience yet to fix it.

I have tried rearranging this code in a ll sorts of ways and have also tried reducing the setInterval function time to every 5 seconds and it still behaves strangely.

I tried using the seekbar component originally but it doesn’t work with YT Chromeless.

Need to see your UpdateProgress function too.
This should be called immediately on ProgDrop as well as via the setinterval.
It may be an issue related to keyframes in your video - you can only navigate to a location with a keyframe. Depending on how your video has been encoded, these may be fairly regular, or may be many seconds apart which might cause playhead glitching. I’d test it with a known encoded video with many keyframes to eliminate this as a cause.

Hi there,
Thanks for your interest, this is really kicking my ass atm have already wasted a day on it:


function UpdateProgress():void
{
	  ratio = Math.round((player.getCurrentTime()*prog_width)/duration);   // do the math to divide down the total time progress range 
		mcPanel.prog_slider.prog_handle.x = ratio;  // multiply the new x position by the ratio
}

I have someone else’s working code and he is calling a similar function every 200ms, I can’t even get away with 3 secs before firefox starts getting confused and the drag event and the update progress function battle it out for the mouse. I have managed to speed it up on some browsers(IE is ok surprisingly), I did this by creating a new variable, duration, I presumed that the call to player.getDuration() in the above function was causing the overhead but it is still there.

The Video is dynamically loaded from YouTube (it is a chromeless player so I have built all the buttons but YT are responsible for the loading and streaming). I tried different vids(including one used on another error-free chromeless) and it still happens and other people have it flawless so its not an API bug.

More than anything I just want to know why this is happening.

Kind regards

Silversurfer

Could be a scope issue where the interval isn’t getting cleared correctly - you’re doing a setInterval in progdrop that hasn’t been designated, which will never get cleared by clearInterval(my_interval);