Skip navigation
Currently Being Moderated

Problems Using Cue points to Loop Video

Mar 15, 2013 11:58 AM

Tags: #flash #as3 #actionscript3

Ok, so I want to use cue points to navigate through video.  I want to start by simply looping the video from the end back to the beginning.  I keep getting an invalid seek error 1003.  Here is my code.  Any help would be much appreciated.  Thanks

 

import fl.video.MetadataEvent;

 

 

 

Movie.addEventListener(MetadataEvent.CUE_POINT, loopFunction);

function loopFunction(e:MetadataEvent):void

{

    if (e.info.name == "end1")

    {

        Movie.seekToNavCuePoint("beginning1");

        Movie.play();

    }

}

 
Replies
  • Currently Being Moderated
    Mar 16, 2013 6:18 AM   in reply to EverestJ

    If you're literally trying to seek to the 00:00 of the video you don't need to incur the extra cycles necessary to loop through available valid cuepoints, just use: Movie.seek(0); to seek second 0. Note, when you seek it will not be a seamless loop, it will take a brief delay before looping. This is a very long standing issue that fluxuates between being an issue, getting resolved, then reappearing. You can search for seamless looping in here and see tons of lengthy threads on the issue.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 17, 2013 1:11 PM   in reply to EverestJ

    I believe it's a faulty metadata to be honest because after a certain duration you can no longer set cue points (I have a bug report on it). Perhaps 00:00 is a 'special' time or something so easily accessed by just seek(0) that they didn't feel the need to implement it. Either way I'm glad you got it working. If you're all set please mark any helpful/correct to close the thread. Good luck!

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 18, 2013 8:30 AM   in reply to EverestJ

    Let's start by seeing if your loopFunction is being fired off. Put a trace in it:

     

    function loopFunction(e:MetadataEvent):void

    {

         trace("Cue point hit, name[" + e.info.name + "] time[" + e.info.time + "] type[" + e.info.type + "]");

    }

    Are the cuepoints firing off at all? I'm trying to determine if the condition isn't being met so it's not seeking (e.g. e.info.name == "introEnd"). Also how long is this movie and what exactly is the "Movie" var representing, a FLVPlayback component?

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 18, 2013 8:46 AM   in reply to EverestJ

    There are different cue point types. Some encoders know this (like Sorenson Squeeze) and when you're encoding you specify the type it should be.

     

    You said the trace is working. Does that mean just in CS5.5 or in both CS5.5 and CS6? If it's working in CS6 then put the same trace inside your comparison and see if it still traces:

     

    function loopFunction(e:MetadataEvent):void

    {

       if (e.info.name=="introEnd")

       {

          trace("introEnd cue point hit, name[" + e.info.name + "] time[" + e.info.time + "] type[" + e.info.type + "]");

          Movie.seekToNavCuePoint("introMiddle");

          Movie.play();

       }

    }

     

    If not you know the issue is the comparison. It can help to be strict in "type" by casting e.info.name to a String before comparison, e.g.: String(e.info.name) == "introEnd"

     

    Let me know where exactly the trace is working.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 18, 2013 3:09 PM   in reply to EverestJ

    At least you are getting notified even if the seek doesn't work.

     

    A brief workaround could be to iterate over the cue points you detect in metadata, assigning each cue point name and time in an object. Once you hit the cue point you desire, see if the object has the time value and seek() to the time for that cue point rather than seeking for it by name.

     

    e.g. (written briefly, you get the idea):

     

    // object to hold time values

    var cuePointArr:Object = new Object();

     

    function onMetaData(infoObject:Object):void

    {

        var cueIndex:String;

        for (cueIndex in infoObject.cuePoints)

        {

            trace("Adding cue name[" + infoObject.cuePoints[cueIndex].name + "] at time[" + infoObject.cuePoints[cueIndex].time + "]");

                        // store as name = time

                        cuePointArr[infoObject.cuePoints[cueIndex].name] = infoObject.cuePoints[cueIndex].time;

        }

    }

     

    function loopFunction(e:MetadataEvent):void

    {

              // correct cue point and has a value in cuePointArr?

        if ((e.info.name == "end1")&&(curPointArr[e.info.name] != null))

        {

                        // seek to time value

            Movie.seek(Number(cuePointArr[e.info.name]));

            Movie.play();

        }

    }

     

    Moving 900mph here so forgive any typos but turning it into a normal seek based on the time value should work for now.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 19, 2013 7:15 AM   in reply to EverestJ

    There's no shortage of workarounds so the lesson to learn there at school on that project is expect the worst to happen, right before deadline, out of the blue . You're welcome and good luck!

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points