AS3 How to navigate to a certain CuePoint
I'm searching the web for hours and days as well as the Adobe Help and Docs, but I do not find any answer. Could you provide some help, please?
Problem is following:
I have two .flvs containing navigation cuepoints. If in vid1 a cuepoint is reached vid2 should goto the next cuepoint and stop. (BG: vid1 is the video of a speaker, vid2 are the slides of the presentation, if I skip by clicking a button it should also skip presentation to keep it synchron) (forgive me my bad english)
Im getting more and more confused with onMetadataEvent and onCuePointEvent, what's the best way to bring it all to a dvd in the end. NetStream or FLVPlayback? Using NetStream I cannot use Eventlisteners to check the appearence of a cuepoint (is that right?).
I have the following code with NetStream so far:
var nc:NetConnection = new NetConnection();
var ns:NetStream = new NetStream(nc);
ns.client = this;
// ignore error
var vid:Video = new Video();
vid.x = 552
vid.y = 132
var nc2:NetConnection = new NetConnection();
var ns2:NetStream = new NetStream(nc2);
ns2.client = this;
// ignore error
var vid2:Video = new Video();
vid2.x = 0
vid2.y = 132
Questions are: How can I tell the function just to "listen" only to CuePointEvents of vid1? And:
How can I tell ns2 to go to a certain CuePoint? seekToNavCuePoint doesn't work! I'm just able to pause and play the ns2 (vid2)...
btw: I'm using Flash CS4 and imported the NavCuePoints with PremiereProCS4 (and checked them with MediaEncoder and Flash, they're there!) Cuepoints are named CP1, CP2... in vid1 and poin1, point2... in vid2.
Thanks a lot for any help you can give.
there are 2 types of cue points: navigation type cuepoints, and event type cuepoints.
navigation cue points are used to seekto ( go to ) those point(s).
event type cuepoints are used to trigger events(functions) when they are reached.
one can't be used for the other.
to simplify it, let's use a FLVPlayback component for now and forget about NetStream.
a FLVPlayback is given a listener to listen for a MetadataEvent. the cue points are embedded in and passed along with the flv's metadata. other ways can work, but the fail safe way to embed cue points is by using the Flash Media Encoder.
so now just write the code that tells your first FLVPlayback to listens for the cupoint, and to trigger a function which tells the 2nd FLVPlayback to seek to its cuepoint and play.
i know this didn't answer all your questions, but it should get you started.
simplest scenario - there are 2 FLVPlayback components, with the instanc names of 'flvPlayer1' and 'flvPlayer2" . vid1.flv has an Event Cuepoint named 'cue1' and vid2.flv has a Navigation Cuepoint named 'cue2'.
this code will then make vid1's cupoint rigger vid2 to play at its cuepoint:
hope this helps. cuepoints can a first seem tricky, but they do make sense, and are a great tool to work with. i am not a big fan of ActionScript cue points, i prefer to always use embedded cuepoints - which are also more accurate.
tip 1- be careful in your coding. if your navigation cuepoint's name is : point1 , then it needs to be written within quotes when using seek to : ns2.seekToNavCuePoint('point1');
tip 2- if you did set the Nav cue points from PremiereProCS4, once brought into Flash Media Player, you can convert the Cue Point type to Event type. can Premeire export Event type cue points ?? ( i'd like to know as i don't use Premeire)
Thank you very very much! This helped me really.
It works. I just had to render the .flv new to change cuePoints from navigation to event, 'cause I didn't find how to change (just to disable) in flash.
Now I just have to write lots of functions to link each cuePoint to the one of the other video. But that's ok in the first step. I will refine this later when if've got the time.
And I will have to find a solution with NetStream, because these are several hours of video so that the projector.exe will be very big, I guess...
To answer your question: Yes its possible and very comfortable to set CuePoints in PremiereProCS4. Just set a marker at the point you want doubleclick and enter options like Name,Parameter, Type(evt or nav) and Time (which is not neccesarry, because it is at the time you selectet in the timeline, but you can adjust framewise if you want to)
Rendering the file with AdobeMediaencoder gives you the possibility to check and/or rework those cuepoints, and all details are passed to the .flv.
Thanks again, you showed me a way out of the dark;-)
(into the next tunnel which is on my way to a flash-pro...)
glad it is working now for you - now comes the 'drudge' work of finishing he code !
thanks for the info on Premiere. it is good to know that it can embed both types of cue points.
Sorry to bother again. But as I want to refine the code I'm wondering abaout a certain line:
Could you please tell me what that means?
Background is, that I want to do a "for loop" to save the time writing a new function for each cuePoint's name. I want to replace the value of "cue1" (which is meanwhile renamed to just "1") by a variable.
But I cannot find out how to because I don't even have a clue what kind of data this is.
My last try was a code like this:
The NavCuePoints where also renamed o'corse. But this doesn't even give me a trace, so I assume that it's not that simple.
I've even tried to create a Object, but as I'm very new to oop at all it didn't work...
If you could be so good to give me again a helping hand and a hint.
I'm wondering abaout a certain line:
Could you please tell me what that means?
"cue1" was the name of the cue point - the event cue point , so
the video player component named 'vid1' has an event listen that is listening for a CuePoint Metadata event. remember that the cue point is embedded in the flv, so it is part of the metadata that is sent along with the video file, as it reaches an event ( coming across a new or next cue point for example), the function is asking it " if the name of this event ( that is, the cue point...) is named 'cue1', then perform what is next in the function". that is how you read that part of the code.
i question your wanting to use a for loop. if the variable 'n' supposed to be cuepoints named 1, 2, 3, then are all these in the same video ? if so, then you probably want an 'if' statement/conditional, or a more readable 'switch' conditional statement to say" if the event is named '1' , then do this, if the event is named 2, then do that, if the event is named 3, then do such-and-such.
something like this:
but if you were to use the 'for' loop, you should type cast the variable as either a uint or int , so the compiler knows to expect a number when it sees the variable 'n'
for loops are usually used with arrays, so you would declare an array with all your cuepoint names
i hope this helps as i am now unsure as to what you are trying to achieve. what i thinkyou are wanting is a video player to play video 1 which has 100 cuepoints, and every time it reaches a cue point, it triggers video player 2 to play video 2 from the same cuepoint name. is that right ??
That's right. But actually I don't know how much cuePoints are in the videos, yet. Perhaps I have to explain a bit better:
There was a conference of my company where we did video of the speakers and I want to produce a dvd where this video is shown. As we do have just the speaker in this vid1 I converted the presentations of each speaker into a video (vid2).
I used CuePoints in vid1 (EventCues as you told me) when the speaker goes too the next slide. (And NavCues in vid2 at the point where this slide is.)
I want the user to be able to use the navigation buttons (either of flvPlayback or own - I have to deciede later) to navigate through the video. As the conference had three days of presesntations with different lenghts and different numbers of charts/slides I dont want to write a function for each cuePoint"x" in vid1 to call cuePoint"x" in vid2. I thought it should be possible to write something like 'if in vid1 MetadataEvent.name==var then in vid2 gotoCuePoint.name==var'
Shure this is no code, but to tell you my intentions.
btw. I made NavCues in vid1 which are 5 frames infront of the EvtCues, so that if the user navigates by clicking the the skip buttons to a cuePoint shortly after he reaches the EvtCue and the onMetadataEvent can be triggered.
And as there are three days of video I thought of using netStream in the beginning. But that's ok, I will split it in different .swfs...
I hope it's better to understand now.
I thought to use if-loop because the possibility to navigate backwards is given and vid doesn't go forward only.
What I was wondering was: Which type has the info.name? unit, int, string, number? I didn't find in FlashHelp that the MetadataEvent has a parameter that is named info.name...
The n<100 was just to tryout the trace. As I cannot know how often the user steps back and forth I don't know how many EvtPoints will be reached, so I have to read out vid1.EvtPoint.name to a variable a and pass it to the function seekToNavCuePoiint(a);
Thanks very much again for your time and patience. You did help me a lot, yet. And I will now test a bit with the results of your last post. I think it could work with unit...
working from your scenario, here are some random thoughts and questions:
you say are publishing to a DVD to distribute. Are you expecting that this is a auto-run DVD to play in DVD players/TV sets, or it this going to made as a data only DVD for use in computers?
i am assuming it is going to be a computer disk, and it is on a DVD because of the large files needed to be there. are you compressing your video to optimize file size vs playback quality for viewing on their screen?
so different speakers will all be gathered on video1 while their presentations are gathered on video2 ? are the presentations static ( like powerpoint slides ) or are they actual videos? because you might be better off having each presentation as a movie clip symbol ( or external swf) that can be loaded in as triggered by the event cue-points in video 1. just a thought..
event.info.name is a STRING. the cue point name is a String embedded in the metadata.
you should have at least a nav and a coresponding event cue point in video 1 for each segment/speaker. video 2 needs at least a nav cue point and also an event cue point ( if you want a 'stop' after each presentation)
then using an array of the vid 1 event cue point name( = vid 2 nav cuepoint name), you can then, with the addition of 2 variables - 1 as a uint to use for a counter and another as a boolean check, keep track of your chapters/speakers and their presentations, whether video 1 just plays by itself, or the user clicks through it with a next/previous buttons., it just takes some specific logic to keep track of it. an 'if' conditional statement would be used, but a loop is not needed. of course, as always, there are different ways to acheive the same ends. **
these are the kinds of logic situations i regularly tackle for clients. i've already developed projects like this. maybe if i find some extra time i will post a working example of this type of project if there is still interest.
i hope this further helps your thinking about how to lay this all out.
** for instance, you can use imported classes like "fl.video.CuePointType" which combined with the MetadataEvent can tell you exactly what the name and type of the cuepoint event is, and then that info can be passed along to the 2nd video player. this is not 'wrong', but it involves extra steps, and therfore processor usage ( which is another reason why to try to avoid loops if possible). if i have a choice i always try for the simplest way possible.
thanks again for all your help.
You're right, it will be a DVD for computers only, due to the ammount of data.
The presentations actually are PowerPoint. And you are absulutely right, that I should not convert them to a video to import them into flash. But I didn't even think that there is a way doing it otherwise. Thanks for that hint.
I will try my best to figure out the code that works. (Due to your help, I guess I can do it).
The interest for your code is still there, even when the project is finished, at least for learnings sake. But as I know (or at least assume;-)) that you have to do some work to earn some money please do not stress yourself. You helped me a lot so far and I'd like to thank you again.
I guess I do understand a bit more about as3 and oop at all.
and all who have or will have the same Problem.
I figured out a working code.
vid1 is the speaker and contains just Navigation CuePoints with the names "1", "2", "3" ..
vid2 is (at the moment) a video with the slides of a presentation and NavCuePoints in it with the same names ("1", "2", "3"...)
starting the .swf gives you the tha ability to see the video1 and when a CuePoint is reached it makes vid2 to jump to the cuepoint with the same name as vid1's point.
Furthermore the user has the chance to jump to next or previous cuepoints by clicking the skip buttons of the built in flvPlayback controlls.
Thanks a lot once more for all the help and assistance.
firstly i want to say thank you for this thread it has helped me understand cue points a bit better.
I am currently seeking some advice concerning cue points.
Lets say that i have an flv playing and want to interact with the cue points but i want the flv to first reach the end of one cue point then direct it to another.
In other words what i would like to achieve is an interactive film experience. So basically i have one flv with cue points. Then at a certain cue point i load a button that runs down (acting as a timer). then i want the viewer to be able to select an option but i don't want the trigger to happen instantaneously. I want the flv to first finish playing the cue point and then when it is finished decide what the users input was and then skip to the cue point that is relevant.
i'm kinda new to AS3, i think the approach would be something like a if statement with a variable that is link to the button.
if( x=1 && cupoint)
i apologize if the syntax is incorrect.
Is it possible that you could help me with the syntax for the example that you used in order to achieve my desired effect?
hi luke. if you've reviewed this and the and the other recent threads about cue points then you understand there are 2 different types you can embed : event type cue point to trigger events, and navigation type cue points to let you seek to ( scrub to...) that location
so i would think you need cue points embedded/placed in this sequence/configuration :
where Nav1 allows you to seek to the first section. immediatetly after that is Event 1a cue point which would trigger this function:
- your countdown clip starts, and also, if i understand you correct, it also triggers some buttons to appear to make a next selection. clicking one of those buttons triggers another function:
- the button click is stored as a variable "buttonclicked"
then it keeps playing until it reaches Event1b, which trigges this function:
- this is either a stop, and/or it directs it to jump to(seek to) "buttonclicked" which is the navigation point coresponding to the button that was selected.
that is certainly one logical way to set it up. these threads have working code examples you can follow for the correct coding syntax.
i hope this all makes sense and helps.
I cant thank you enough for the quick response.
I will most certainly get to work on this asap.
again thanks for your help.
anyway you mentioned that i should use embedded cue points or nav cue points, i assume you are not referring to cu points i must add in AE. or should i?
the senarion is as follows; i have a white circle that fades in and when at 100% opacity is where you should have made a choice already. so the next part is that you can choose between green and red. they also fade in. thus if you dont make a choice it just fades the white circle out.
i understand the logic that you have shown me, but i still cant figure out how to create the event listener that only acts at the end of the certain cue point. i know this might be an easy solution for you, but it feels like a mountain i just cant get across.
here is the code:
so finally i would like to ask you if you could maybe help solve this tiny problem that i have. if you could give me an example of a piece of code i would jump up and down with joy.
i think the answers did lie in previous posts. but never-the-less, if you do have your video set up with this configuration of cue points:
then code like this should make it work. note that this code was written in the browser, so it was not tested for erros:
hope that helps you out
I never considered a switch.
I'm going to give it a try and get back to you.
thanks again for your time.
your code produced a weird error something like error:1003 and a long list of adobe references. anyway i finally got it to work
here is the code
now i need to just figure out little kinks to fluff up my concept and implement my film.
unfortunately the switch function i still dont get, but i will figure it out if i need to clean the code.
there is just one little thing that i just cant figure out, if at all possible would you mind taking a look. if the person does not make a decision i want to code it to pick a random button to pick a random button. i have look at the eventHandler functions to figure out if their is something like if no event then do something or noclick do something, but unfortunately im stuck. any guidance here?
i experimented with removingChild in this piece of code to see whether it can be dont removed here but then i get the error:1003 if the user has not clicked the button:
if i can figure out the random button thing the above code will not require the removeChild function. because once you click the button the removeChild function works fine in the cuepointfound function.
so actually the above code is more of an example of where not to put the removeChild().
i would just like to thank you for helping me out once again. your help has proved invaluable to me. and i will definitely refer my peeps to creative cow, awesome resource and awesome response time on the forums.
I meant that the code above is for one button only not one cue point.
Hope this helps someone out when in a pickle.
of course you will get errors if you are saying to remove something ( removeChild(btn) ) if it is not placed/added to the display list yet....
if you want a random button choosen , you might consider a timer set once it reaches the pause, that deploys after a few seconds to choose a random button if none has been choosen up to that point.
Is there a code sample you can put up for the logic you just explained? I understood the logic, but it's the code I'm having trouble with. I'm new to AS3.
Also, can you help me figure something else out? I have the same situation as the person who initiated the thread, but the in my version, I have multiple speakers, so I cut out the speakers and left the audio, synced the audio and the slides together, and exported them with navcues as flv files. The problem I have, since I'm new to all this, is my customer wants a Previous Module and Next Module button. Essentially, the buttons go back one and forward one video. But he also wanted seek points in each video. So he wanted to be able to view certain slides in each video as well as go between videos. Can you or anyone help me figure out out to do this? I thought I had something, but it only worked within one video.
Thanks in advanced for any help!
what code example are you talking about? this thread got kind of long and there was a lot of code examples already posted on it, so i don't know what specifically you are referring to.
as far as your other question - we will need more information, because
"customer wants a Previous Module and Next Module button. Essentially, the buttons go back one and forward one video"
really doesn't tell to much. are these "modules' all separate external swfs? loading via xml ? are they movieclips added from the library? or are you putting them on a timeline ?
if you want some overall suggestion, i would start by having each 'module' as a separate self contained external swf. this would have its own navigation buttons to get to specific cuepoints
then a loader on the main swf can load in a module at a time. all the module names can be in an array.
then you can script a 'next' and a 'previous' button to load in the next/previous module based on its array position. then you would acheive independent navigation to a specific module, and witin each module you would have the navigate to cuepoints ability built in to each module.
hope this anwers your question. if not, please start a new thread which can go deeper into it, as this has mpw veered off the topic of this original post.
I have a similar problem. I have a quiz that's written in AS2 but I need to get it to play a specific cue point when it's finished. The way it works is if the user passes the quiz, it goes to the main swf which is a separate file, not embedded. If they pass the quiz, it plays the next cue point from where it left off. If they don't pass, it makes them repeat the one they just finished. Can anyone help me figure out how to code out the part where passing takes you to the next cue point in the external swf and failing takes you to the one you just played?
i would like to help you but i can't understand the layout and structure of your project at all from the way you are describing it.
the quiz is a video ( flv ) being played ? and answering a question generated from the flv ( assumed generatd by an Event cue point being reached ) will then effect the main timeline ?
i am sure everything is quite doable, if you can just layout the structure for us clearly and logically . can you post an example of what you have done so far ? or post some source files ?
I am trying to navigate to a certain point in my video. I currently have the outplay off and I am trying to start it using cue points. Basically using a button to play the movie when clicked, and then stop the video when clicked again.