17 Replies Latest reply on Sep 28, 2006 11:39 AM by Newsgroup_User

    Cue Points

    Pewee2000
      I have a flv which im loading in from another location (ie its not embeded), and Im trying to create a loop point using cue points.
      I have 3 cue points: begining, loop_point, end
      Basically when the playhead reaches the "end" cuepoint, I want it to jump back to "loop_point"

      Can anyone help? I have a deadline for monday to get this finished!
        • 1. Re: Cue Points
          Level 7
          Pewee2000,

          > I have 3 cue points: begining, loop_point, end [for an FLV].
          > Basically when the playhead reaches the "end" cuepoint, I
          > want it to jump back to "loop_point"

          How have you loaded your FLV? Media Component, FLVPlayback Component,
          Video object with ActionScript?


          David Stiller
          Adobe Community Expert
          Dev blog, http://www.quip.net/blog/
          "Luck is the residue of good design."


          • 2. Re: Cue Points
            Pewee2000 Level 1
            Im using flash 8. I just used the 'import video' and selected 'stream from server' option

            so not sure what you mean.
            • 3. Re: Cue Points
              Level 7
              Pewee2000,

              > Im using flash 8. I just used the 'import video' and selected
              > 'stream from server' option
              >
              > so not sure what you mean.

              Then we have a few concepts to explore. Your FLV (the video file
              itself) is being displayed in Flash. There are a number of ways to display
              the video, including the use of one of the Media Components (see the
              Components panel), the FLVPlayback Component (again, see the Components
              panel) or a Video object and some ActionScript, as described here ...

              http://www.quip.net/blog/2006/flash/how-to-load-external-video

              Depending on how you imported your video, Flash may have already
              provided you with an instance of the FLVPlayback Component on your Stage.
              Do you see something that looks like a video player?


              David Stiller
              Adobe Community Expert
              Dev blog, http://www.quip.net/blog/
              "Luck is the residue of good design."


              • 4. Re: Cue Points
                Pewee2000 Level 1
                Oh sorry I get what you mean now. Yeh I imported without player and used seperate componants from the
                flv custom playback UI panel to control the movie.
                • 5. Cue Points
                  Pewee2000 Level 1
                  Anyone there?
                  • 6. Re: Cue Points
                    Level 7
                    Pewee2000,

                    > Oh sorry I get what you mean now. Yeh I imported without
                    > player and used seperate componants from the flv custom
                    > playback UI panel to control the movie.

                    Okay, I'm not exactly clear on what you just said, so I'm going to
                    proceed as if you're using the FLVPlayback Component. Here's the scoop on
                    using ActionScript. Just about everything is an object. Objects are simply
                    "things" that behave a certain way. Movie clips are objects, buttons are
                    objects ... FLVPlayback Component instances are objects -- you get the idea.
                    :) Objects are defined by something called classes. Think of a class as a
                    given object's blueprint. You'll genearally see up to three categories in a
                    class: properties, methods, and events. Properties are characteristics an
                    object has, such as a movie clip's width and height. Methods are things an
                    object can do, such as movie clip's ability to gotoAndPlay() some frame.
                    Events are things an object can react to, such as a mouse click.

                    In your case, the FLVPlayback events include a cuePoint event. You can
                    see detailed information -- often including sample code -- for all the
                    properties, methods, and events of the FLVPlayback class by looking up the
                    phrase "FLVPlayback class" in the Components Language Reference right in the
                    built-in Help documentation. Component classes are listed in this
                    reference, and normal classes are listed in the ActionScript 2.0 Language
                    Reference. In the AS Language Reference, the three categories are combined
                    in each class entry, but for some reason the Components Language Reference
                    separates them. But you'll see 'em when you look up the class.

                    You'll want to take things slow and start with a *simple* example.
                    Assuming you've added cue points through the Component Inspector panel, your
                    FLV will honor those cue points during playback. Start your journey by
                    looking up the cuePoint event in the "Event summary" section for the
                    FLVPlayback class.

                    You'll see this:

                    var listenerObject:Object = new Object();
                    listenerObject.cuePoint = function(eventObject:Object):Void {
                    // insert event-handling code here
                    };
                    my_FLVplybk.addEventListener("cuePoint", listenerObject);

                    ... which may look scary if you're not a coder, but it works like this:
                    first, a variable named listenerObject is delcared as a generic Object
                    isntance. This object is your "ambassador" for the FLVPlayback instance,
                    which features the cuePoint event. You assign a function to a new cuePoint
                    property of your generic object. This function will be executed when any
                    cue point occurs. Finally, you use the addEventListener() method to
                    "subscribe" your FLVPlayback instance to the generic object, listenerObject.
                    Now you're "listening" for cue points.

                    In the above example, the instance name for your FLVPlayback instance
                    must be my_FLVplybk -- but you can make it whatever you like, as long as the
                    ActionScript matches the instance name.

                    Where it says "// insert event-handling code here," you may want to use
                    a trace function ...

                    trace("Here's a cue point!");

                    ... just to prove to yourself that it works. Read up in the documentation,
                    and you'll see that the eventObject object received by the function contains
                    valuable information about the FLVPlayback instance that dispatches the
                    cuePoint event. You can trace eventObject.target, for example, and get a
                    reference back to your FLVPlayback instance.

                    trace(eventObject.target);

                    That reference would let you refer to the FLVPlayback instance and
                    invoke FLVPlayback methods on it, such as your various seek options for
                    looping.


                    David Stiller
                    Adobe Community Expert
                    Dev blog, http://www.quip.net/blog/
                    "Luck is the residue of good design."


                    • 7. Re: Cue Points
                      Pewee2000 Level 1
                      Thanks thats really helpfull. I managed to get it to throw some text back at me and some other cool stuff, but im not sure what code to use to tell the flv to jump back to previous cue point.
                      • 8. Re: Cue Points
                        Level 7
                        Pewee2000,

                        > Thanks thats really helpfull. I managed to get it to throw
                        > some text back at me and some other cool stuff, but im
                        > not sure what code to use to tell the flv to jump back to
                        > previous cue point.

                        Did you get as far as tracing eventObject.target? If so, you're about
                        as close as it gets. eventObject.target gives you a reference to the
                        FLVPlayback Component instance that raised the cuePoint event in the first
                        place. In other words, the expression eventObject.target is the same as
                        simply referring to the FLVPlayback instance by instance name. Which means
                        you can invoke FLVPlayback methods on the expression.

                        var listenerObject:Object = new Object();
                        listenerObject.cuePoint = function(eventObject:Object):Void {
                        eventObject.target.seek(); // specify where to go
                        };
                        my_FLVplybk.addEventListener("cuePoint", listenerObject);


                        David Stiller
                        Adobe Community Expert
                        Dev blog, http://www.quip.net/blog/
                        "Luck is the residue of good design."


                        • 9. Re: Cue Points
                          Pewee2000 Level 1
                          So the instance of the flv is: fellowfilm
                          it has three navigation cue points encoded into it: begining, loop_point, end
                          when cue point "end" happens, I would like it to jump either to previous or the named cue point "loop_point"
                          from your code what would I have to add?
                          • 10. Re: Cue Points
                            Level 7
                            Pewee2000,

                            > So the instance of the flv is: fellowfilm

                            That's cool, but you don't even need the instance name, since
                            eventObject.target points to it for you.

                            > it has three navigation cue points encoded into it: begining,
                            > loop_point, end when cue point "end" happens, I would like
                            > it to jump either to previous or the named cue point "loop_point"
                            > from your code what would I have to add?

                            Have you looked at the FLVPlayback method summary yet? ;)

                            var listenerObject:Object = new Object();
                            listenerObject.cuePoint = function(eventObject:Object):Void {
                            if (eventObject.name == "loop_point") {
                            // do what you like with the FLVPlayback instance here
                            eventObject.target..findCuePoint();
                            eventObject.target.seek();
                            // etc.
                            }
                            };
                            my_FLVplybk.addEventListener("cuePoint", listenerObject);


                            • 11. Re: Cue Points
                              Pewee2000 Level 1
                              var listenerObject:Object = new Object();
                              listenerObject.cuePoint = function(eventObject:Object):Void {
                              eventObject.target.seek("loop_point");
                              };
                              fellowfilm.addEventListener("cuePoint", listenerObject);

                              is as far as I got, but that wont go anywhere as its not looking out for "end" cue point,
                              to tell it to go to "loop_point"

                              not sure what to do
                              • 12. Re: Cue Points
                                Level 7
                                Actually, you'd only be interested in the "end" cue point, so change the
                                quoted part from "loop_point" to "end" here ...

                                > if (eventObject.name == "loop_point") {
                                > // do what you like with the FLVPlayback instance here

                                Make sense? You only care of the cue point is the "end" cue point, so
                                your if statement handles that. Inside that if statement, do what you like.
                                Maybe you'll use findCuePoint() and supply the name "loop_point" as your
                                parameter (see the Components Language Reference for details -- look up
                                these methods). That would return you the cue point object for
                                "loop_point", and that object will have a time property that tells you the
                                time to send to the seek() method.


                                David Stiller
                                Adobe Community Expert
                                Dev blog, http://www.quip.net/blog/
                                "Luck is the residue of good design."


                                • 13. Re: Cue Points
                                  Pewee2000 Level 1
                                  I tried

                                  var listenerObject:Object = new Object();
                                  listenerObject.cuePoint = function(eventObject:Object):Void {
                                  if (eventObject.name == "end") {
                                  seekToPrevNavCuePoint("loop_point")
                                  }
                                  };
                                  fellowfilm.addEventListener("cuePoint", listenerObject);


                                  but it just plays the whole thing and stops
                                  what am i doing wrong? It doesnt complain about the code
                                  • 14. Re: Cue Points
                                    Pewee2000 Level 1
                                    This code works, but only when it is uploaded. I want it to work localy


                                    /**
                                    Requires:
                                    - FLVPlayback component on the Stage with an instance name of my_FLVPlybk
                                    */
                                    import mx.video.*;
                                    my_FLVPlybk.contentPath = " http://www.fellowproductions.com/looping_logo.flv";
                                    var listenerObject:Object = new Object();
                                    listenerObject.cuePoint = function(eventObject:Object) {
                                    if(eventObject.info.name == "end")
                                    my_FLVPlybk.seekToPrevNavCuePoint(eventObject.info.time);
                                    }
                                    my_FLVPlybk.addEventListener("cuePoint", listenerObject);
                                    • 15. Re: Cue Points
                                      Level 7
                                      Pewee2000,

                                      Ah, good to see you're still working on this. I was in the middle of
                                      replying again.

                                      > This code works, but only when it is uploaded. I
                                      > want it to work localy

                                      I've got a version of my own that works locally.

                                      > import mx.video.*;
                                      > my_FLVPlybk.contentPath =
                                      > " http://www.fellowproductions.com/looping_logo.flv";
                                      > var listenerObject:Object = new Object();
                                      > listenerObject.cuePoint = function(eventObject:Object) {
                                      > if(eventObject.info.name == "end")

                                      That extra property, info, is key ... my apologies for leaving that out
                                      earlier. The object returned by the dispatched cue point -- in this case,
                                      eventObject -- contains a number of properties, including target. But the
                                      name and time properties are stored inside the info property. So you're
                                      correctly using eventObject.info.name here.

                                      > my_FLVPlybk.seekToPrevNavCuePoint(eventObject.info.time);

                                      Here, you can either name the FLVPlayback Component instance explicitly,
                                      as you've done, or you can use the target property I mentioned earlier ...

                                      eventObject.target.seekToPrevNavCuePoint(eventObject.info.time);

                                      In my own example, I wrote it as if "loop_point" wasn't necessarily the
                                      previous cue point (because it might not be, depending on the
                                      circumstances). Here's my approach -- not better, just different.

                                      var listenerObject:Object = new Object();
                                      listenerObject.cuePoint = function(eventObject:Object):Void {
                                      if (eventObject.info.name == "end") {
                                      var time:Number = eventObject.target.findCuePoint("loop_point").time;
                                      eventObject.target.seek(time);
                                      }
                                      };
                                      videoPlayer.addEventListener("cuePoint", listenerObject);

                                      Make sense?


                                      David Stiller
                                      Adobe Community Expert
                                      Dev blog, http://www.quip.net/blog/
                                      "Luck is the residue of good design."


                                      • 16. Re: Cue Points
                                        richy66
                                        Hey Dave Stiller.

                                        I've been having the same problem and have been scratching my head for the last three hours before I found this thread.

                                        I'd just like to say thanks, it works a treat!
                                        • 17. Re: Cue Points
                                          Level 7
                                          richy66,

                                          > I've been having the same problem and have been
                                          > scratching my head for the last three hours before
                                          > I found this thread.
                                          >
                                          > I'd just like to say thanks, it works a treat!

                                          Rock on!


                                          David Stiller
                                          Adobe Community Expert
                                          Dev blog, http://www.quip.net/blog/
                                          "Luck is the residue of good design."