Sync main Flash timeline with cue points in Flash video

I have a Flash video with a cue point at the beginning (vidStart) and a cue point at the end (vidEnd). The main timeline starts with a static graphic over the video; when the user clicks Play, a listener object hears "vidStart" and moves to frame 2 of the main timeline, where the graphic no longer covers the video.

At the end of the video, the listener object hears "vidEnd" and advances to frame 3 of the main timeline, where there is another static graphic and some buttons. So far so good.

THE PROBLEM --- I need to use a Flash Video Playback component that includes the SEEK function, but using seek causes Flash to lose track of where the video is and what graphic should be displayed. I need to be able to track where the playhead is, or at least whether the video is playing or not, so Flash knows what graphics should be shown at the point to which the user seeked. sought. whatever. :)  Any ideas?
LVL 4
slovisaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

blue-genieCommented:
my_FLVPlybk.playheadTime - should tell you where the playhead is.

FLVPlayback.playing will tell you if its playing or not.
slovisaAuthor Commented:
So each frame could use an onEnterFrame command to evaluate the playheadTime and move the main timeline as necessary - is that the most efficient way to do it?

E.G.
onEnterFrame = function() {
      if (myVideo.playheadTime < myVideo.totalTime){
      _root.gotoAndStop(2);
      }
};

If you have multiple captions for one video, I assume you could also create a "if playheadTime is > thisTime but < thisTime, gotoAndStop(#)?
blue-genieCommented:
i'm not understanding why you'd need an onEnter frame - using listeners are more efficient.
you've got different movies in different flvplayback instances right?
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

slovisaAuthor Commented:
Me either. :) But then, listeners are relatively new territory for me.

For some reason, only the keyframe commands have been working with the listener. The playheadTime commands work in an onEnterFrame, but not in the listener. (Can one listener listen for both? Doesn't seem to work even if I separate them. Here are the two methods I'm attempting...maybe you can see where I've gone wrong.


var listenerObject:Object = new Object();
listenerObject.playheadTime = function(eventObject:Object):Void {
	if (myVideo.playheadTime > 0.5){
	_root.gotoAndStop(2);
	}
    if (myVideo.playheadTime == myVideo.totalTime){
	_root.gotoAndStop(3);
	}
};
myVideo.addEventListener("playheadTime", listenerObject);
 
//AND/OR***(keyframes work during normal play, but NOT if user SEEKS)***
 
var listenerObject:Object = new Object();
listenerObject.cuePoint = function(eventObject:Object):Void {
	if ( eventObject.info.name == "vidStart"){
        _root.gotoAndStop(2);
	}
    if ( eventObject.info.name == "vidEnd"){
        _root.gotoAndStop(3);
	}
};
myVideo.addEventListener("cuePoint", listenerObject);

Open in new window

blue-genieCommented:
can u upload your fla (put a .txt extension after the .fla)
 i'll use my own videos.

my brain works better when i can see the thing.
slovisaAuthor Commented:
Sure thing. Thanks for your help!
video-sync.fla.zip
slovisaAuthor Commented:
So far, onEnterFrame is the only way I've gotten it to work, but the points are still available if there's a more efficient solution out there?
blue-genieCommented:
ok if i run your file - i see th graphic, and click play, but there's no play btn. when i look at the file is see there's playback component. but for some reason that isn't showing.

ok, first of all you have the onEnterframe checking the playhead time then going to frame 2, that's duplicating efforts for vidstart cuepoint is it not?

then you have the listener code duplicated in all the frames -  not necessary.

then. you said >> I need to use a Flash Video Playback component that includes the SEEK function,

just to make sure we're on the same page, are you referring to the scrubbing or seeking?
am

then in terms of just checking whether the video is playing ....

var stateObject:Object = new Object();
stateObject.stateChange = function(eventObject:Object):Void {
      if (!myVideo.playing) {
            trace(myVideo.playheadTime);
      }
};
myVideo.addEventListener("stateChange", stateObject);

this says if the video is not playing tell me where the playhead is then you can redirect to frames accodingly.

blu.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
slovisaAuthor Commented:
Hi Blue. I guess I'm not following you - or at least not able to execute the listener correctly. If I use your code above and then create conditional statements based on the video's timeline, it still doesn't behave correctly. Or to be more accurate, it SOMETIMES behaves correctly, which is maddening, since it seems like black & white math...

I do mean scrub, rather than seek to a point: The user can scrub the video any time - if it's not at the end, I need to be in one frame; if it IS at the end, I need to go to the next frame, where there's text and a button overlaying the player.
blue-genieCommented:
did you come right or are you just giving up now?
slovisaAuthor Commented:
Just giving up. I'm sure you're pointing to the right answer, but I haven't been able to get it to work properly.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.