Listeners not working. {update}

  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 23407
  • Loc: Woodbridge VA
  • Status: Offline

Post January 11th, 2006, 2:58 pm

This is related to this topic:
http://www.ozzu.com/flash-forum/testers-feedback-needed-resolved-t57075.html

I have a continuous loop running with that animation and the listener works for that, but there's about a second's glitch from the end to where it starts playing again that I'd like to get rid of. The code that's working is
Code: [ Select ]
myListener = new Object();
myListener.complete = function(){
myMedia.play(snow0008.flv);
}
myMedia.addEventListener("complete", myListener);
  1. myListener = new Object();
  2. myListener.complete = function(){
  3. myMedia.play(snow0008.flv);
  4. }
  5. myMedia.addEventListener("complete", myListener);



What I did was re-encode the video and added two cuepoints - one at the beginning called beginLoop as a Navigation type and one about .866 seconds before the end (about 12 frames before the end) and it's called endLoop

Basically the idea is when the movie gets to endLoop I need it to go back to beginLoop and replay the movie. I've tried many variations of this, and it's got to be close, but it simply plays to the end of the flv file and stops.

Here's the script I'm messing with
Code: [ Select ]
my_FLVPlybk.setFLVCuePointEnabled('true');

import mx.video.*;
var listenerObject:Object = new Object();
listenerObject.endLoop = function(eventObject:Object):Void {
     var cuePtName = eventObject.info.name;
   if (cuePtName == "endLoop") {
   my_FLVPlybk.seekToNavCuePoint("beginLoop");
     }
 };
my_FLVPlybk.addEventListener("endLoop", listenerObject);

var listenerObject:Object = new Object();
listenerObject.beginLoop = function(eventObject:Object):Void {
     var cuePtName = eventObject.info.name;
   if (cuePtName == "beginLoop") {
   my_FLVPlybk.play();
     }
 };
my_FLVPlybk.addEventListener("beginLoop", listenerObject);
  1. my_FLVPlybk.setFLVCuePointEnabled('true');
  2. import mx.video.*;
  3. var listenerObject:Object = new Object();
  4. listenerObject.endLoop = function(eventObject:Object):Void {
  5.      var cuePtName = eventObject.info.name;
  6.    if (cuePtName == "endLoop") {
  7.    my_FLVPlybk.seekToNavCuePoint("beginLoop");
  8.      }
  9.  };
  10. my_FLVPlybk.addEventListener("endLoop", listenerObject);
  11. var listenerObject:Object = new Object();
  12. listenerObject.beginLoop = function(eventObject:Object):Void {
  13.      var cuePtName = eventObject.info.name;
  14.    if (cuePtName == "beginLoop") {
  15.    my_FLVPlybk.play();
  16.      }
  17.  };
  18. my_FLVPlybk.addEventListener("beginLoop", listenerObject);


Thanks
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post January 11th, 2006, 2:58 pm

  • nancyW
  • Novice
  • Novice
  • User avatar
  • Joined: Jul 23, 2004
  • Posts: 22
  • Loc: London, UK
  • Status: Offline

Post January 11th, 2006, 3:39 pm

I might be on completely the wrong track here, but I always try and keep my variable names different from one another, unless i have killed off an object and then I will reuse the variable if I want to create it again.

Perhaps call your listeners listenerObject1 and listenerObject2?

This will end and you will get it to work...your perserverence has been incredibly impressive.
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 23407
  • Loc: Woodbridge VA
  • Status: Offline

Post January 11th, 2006, 4:17 pm

Thanks for the tip. I most likely won't be able to try that until tomorrow, but will definitely give it a shot. And yeah - I have a ton of patience. The more complex something is the more I dig into it. I love learning new things.

//edit -- btw, what does this do?
import mx.video.*;

That was part of code I got from Macromedia's documentation, but I have no idea what it does.
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
  • nancyW
  • Novice
  • Novice
  • User avatar
  • Joined: Jul 23, 2004
  • Posts: 22
  • Loc: London, UK
  • Status: Offline

Post January 11th, 2006, 4:26 pm

A developer after my own heart :). Make sure you let us know when you manage to solve it!
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 23407
  • Loc: Woodbridge VA
  • Status: Offline

Post January 11th, 2006, 4:29 pm

Will do for sure. By the way I edited my post while you were posting.

re:
What does this do?
import mx.video.*;
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
  • SB
  • Moderator
  • Genius
  • User avatar
  • Joined: Nov 16, 2004
  • Posts: 8685
  • Loc: Aberdeen, Scotland
  • Status: Offline

Post January 11th, 2006, 4:42 pm

completely uneducated assumption here ATNO, but would that not be the command for inserting the flash mx file when the page opens?

Sorry for chipping in here.
  • nancyW
  • Novice
  • Novice
  • User avatar
  • Joined: Jul 23, 2004
  • Posts: 22
  • Loc: London, UK
  • Status: Offline

Post January 11th, 2006, 4:42 pm

Basically that allows you to use built in classes which sit in the mx.video package without having to use the full path to refer to them. Essentially you have importing everything from the mx.video package in this statement.

So, for instance, you can use create a CuePointManager object by just declaring
Code: [ Select ]
var myCuePoint:Object = new CuePointManager(whatever, parameters, etc.)
.

If you hadn't imported the package, to create an CuePointManager object you would have needed to write

Code: [ Select ]
var myCuePoint:Object = new mx.video.CuePointManager(blah,blah);


It acts as a shortcut.
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 23407
  • Loc: Woodbridge VA
  • Status: Offline

Post January 11th, 2006, 4:47 pm

gottcha - that makes sense. Sorry for all the questions. I just started playing in Flash about two months ago, and am a complete newb at action script.
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 23407
  • Loc: Woodbridge VA
  • Status: Offline

Post January 12th, 2006, 11:07 am

I tried using the two different names and that didn't work. I also re-encoded it and changed the type from navigation to event, but still no joy. Found a couple things on working with cuepoints that I'm reading through now though.
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Joined: Jul 11, 2005
  • Posts: 1828
  • Loc: In the Great White North
  • Status: Offline

Post January 12th, 2006, 11:54 am

I noticed this in the docs when I tried playing with the FLVPlayback. I assume its why the .complete didn't fire correctly

Quote:
When the application uses progressive download, does not set the totalTime property explicitly, and downloads an FLV file that does not specify the duration in the metadata, the video player sets totalTime to an approximate total value before it dispatches this event.


try adding:

Code: [ Select ]
myMedia.totalTime = time in seconds;


more from MM about the total time

Quote:
For an HTTP download, the value is determined automatically if the FLV file has metadata embedded; otherwise, set it explicitly or it will be 0. If you set it explicitly, the metadata value in the stream is ignored.

When you set this property, the value takes effect for the next FLV file that is loaded by setting contentPath. It has no effect on an FLV file that has already loaded. Also, this property does not return the new value passed in until an FLV file is loaded.
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 23407
  • Loc: Woodbridge VA
  • Status: Offline

Post January 12th, 2006, 12:36 pm

That sounded promising, but no dice. I tried it inside and outside of myMedia.complete and no affect from either. I also added contentPath based on what I was reading in your post and it did nothing to help either. The movie is exactly 84.866 seconds in length. This was the last thing I tried.
Code: [ Select ]
myMedia.totalTime = 84.866;
myMedia.contentPath ="snow0008.flv";
myListener = new Object();
myListener.complete = function(){
    myMedia.play(snow0008.flv);
}
myMedia.addEventListener("complete", myListener);
  1. myMedia.totalTime = 84.866;
  2. myMedia.contentPath ="snow0008.flv";
  3. myListener = new Object();
  4. myListener.complete = function(){
  5.     myMedia.play(snow0008.flv);
  6. }
  7. myMedia.addEventListener("complete", myListener);


I also haven't given up on the cue point thing either. I was becoming concerned that maybe I didn't do the cue points correctly or maybe it wasn't readin gthem so I tried this code and it correctly outputed the correct names type and time of the cuepoints. So at least I'm sure they are there and working. It's just me not knowing enough about action script that's screwing things up *lol

Code: [ Select ]
var listenerObject:Object = new Object();
listenerObject.cuePoint = function(eventObject:Object):Void {
    trace("Elapsed time in seconds: " + my_FLVPlybk.playheadTime);
    trace("Cue point name is: " + eventObject.info.name);
    trace("Cue point type is: " + eventObject.info.type);
}
my_FLVPlybk.addEventListener("cuePoint", listenerObject);
  1. var listenerObject:Object = new Object();
  2. listenerObject.cuePoint = function(eventObject:Object):Void {
  3.     trace("Elapsed time in seconds: " + my_FLVPlybk.playheadTime);
  4.     trace("Cue point name is: " + eventObject.info.name);
  5.     trace("Cue point type is: " + eventObject.info.type);
  6. }
  7. my_FLVPlybk.addEventListener("cuePoint", listenerObject);
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 23407
  • Loc: Woodbridge VA
  • Status: Offline

Post January 12th, 2006, 6:54 pm

Here's my latest code. I'm still missing something, but still stumped. This should work. But it's not.

Specifics:
FLV file is relative so contentPath = "cuepointloop12.flv"
FLVPlayback Instance is my_FLVPlybk
FLV duration is 00:01:24.866 (84.866 seconds)
First cue point is beginLoop at 00:00:00.000 Type=event (no properties set)
Second cue point is endLoop at 00:01:24.000 (no properties set) ( I set it about 12 frames less than the total movie to hopefully elliminate the glitch and make the loop seamless - I can alter that easily if needed if I could get the darn thing to loop to see what it does.
fps = 15
the FLA file consists of one layer and one frame.
I used the standalone FLV Encoder to encode the movie from Studio 8
I'd really like to get this cue point thing down (even if I can't make it seamless in the end, because I've already thought of a dozen things I want to do with it in the future.) *lol

Parameters:
autoPlay=true
autoRewind=true
autoSize=false
bufferTime-0.1
contentPath=cuepointloop12.flv (relative)
cuePoints already listed above
isLive=false (it's a progressive download and not streamed)
skinAutoHide=false
totalTime=84.866
volume=100

I know I'm being very persistant about this so thanks for all of your help so far. It's taken me two months to learn how to do this video stuff, and I've only been playing with this action script since last week when I bout Studio8 so I'm still a complete newb. Thank the good Lord I understand a little bit of programming or I'd be totally lost right now.

By the way - the script has no syntax errors and pretty much mimicks the very few examples and bits of code I could find on this. But I've searched for nearly 3 days now and posted this at the Macromedia forums as well as Kirupa and just can't seem to get a working answer. I guess it's because Flash8 Pro is so new and there's so few people visiting forums that do quality video work. But I refuse to throw in the towel! *lol

Anyway here's the code I currently have. If anyone has Flash8 Pro and wants to take a realtime shot at it, send me a PM and I'll be happy to give you the link to the FLA and FLV files.




Code: [ Select ]
import mx.video.*;
var listenerObject:Object = new Object();
listenerObject.cuePoint = function(eventObject:Object) {
  
   if (eventObject.name == "endLoop") {
     my_FLVPlybk.contentPath = "cuepointloop12.flv";
   my_FLVPlybk.play(my_FLVPlybk.contentPath);
   }
 };
my_FLVPlybk.addEventListener("cuePoint", listenerObject);
  1. import mx.video.*;
  2. var listenerObject:Object = new Object();
  3. listenerObject.cuePoint = function(eventObject:Object) {
  4.   
  5.    if (eventObject.name == "endLoop") {
  6.      my_FLVPlybk.contentPath = "cuepointloop12.flv";
  7.    my_FLVPlybk.play(my_FLVPlybk.contentPath);
  8.    }
  9.  };
  10. my_FLVPlybk.addEventListener("cuePoint", listenerObject);
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 23407
  • Loc: Woodbridge VA
  • Status: Offline

Post January 13th, 2006, 4:43 pm

Made some progress today. Learned a few things about "trace" and how it works and my cuepoints are all working just fine, it seems. Problem is, that nobody has seemed to have ever posted a solid code to get this done seamlessly. So the problem appears to be in identifying when cue point "endLoop" is hit and triggering the action to replay the movie.

I have to be pretty close with this. I'm following the model from Macromedia itself to work with cuePoint listeners but I can't seem to write the function correctly to get it to go back to beginLoop and continue playback. Here's what I have currently

Code: [ Select ]
import mx.video.*;

var listenerObject:Object = new Object();
listenerObject.cuePoint = function(eventObject:Object):Void {
    // Seek to Cue Name Behavior
    var myCue = eventObject.info.name;
    if (myCue == "endLoop") {
    var c = this.my_FLVPlybk.findCuePoint("beginLoop");
    this.my_FLVPlybk.seekSeconds(c.time);
    this.my_FLVPlybk.play("cuepointloop12.flv");
    }
    // End Seek to Cue Name Behavior
    
        
    trace("Cue point name: " + eventObject.info.name);
    trace("Cue point type: " + eventObject.info.type);
}
my_FLVPlybk.addEventListener("cuePoint", listenerObject);
my_FLVPlybk.contentPath = "cuepointloop12.flv";

var listenerObject2:Object = new Object();
listenerObject2.stateChange = function(eventObject:Object):Void {
  trace(my_FLVPlybk.state);
};
my_FLVPlybk.addEventListener("stateChange", listenerObject2);
my_FLVPlybk.contentPath = "cuepointloop12.flv";
  1. import mx.video.*;
  2. var listenerObject:Object = new Object();
  3. listenerObject.cuePoint = function(eventObject:Object):Void {
  4.     // Seek to Cue Name Behavior
  5.     var myCue = eventObject.info.name;
  6.     if (myCue == "endLoop") {
  7.     var c = this.my_FLVPlybk.findCuePoint("beginLoop");
  8.     this.my_FLVPlybk.seekSeconds(c.time);
  9.     this.my_FLVPlybk.play("cuepointloop12.flv");
  10.     }
  11.     // End Seek to Cue Name Behavior
  12.     
  13.         
  14.     trace("Cue point name: " + eventObject.info.name);
  15.     trace("Cue point type: " + eventObject.info.type);
  16. }
  17. my_FLVPlybk.addEventListener("cuePoint", listenerObject);
  18. my_FLVPlybk.contentPath = "cuepointloop12.flv";
  19. var listenerObject2:Object = new Object();
  20. listenerObject2.stateChange = function(eventObject:Object):Void {
  21.   trace(my_FLVPlybk.state);
  22. };
  23. my_FLVPlybk.addEventListener("stateChange", listenerObject2);
  24. my_FLVPlybk.contentPath = "cuepointloop12.flv";


The trace stuff is in there so I could see what is outputed. Essentially, the trace in both listeners works fine, so I can see that it completely ignores any attempt I make to loop this sucker via cue points.

As a sidenote though, I did finally install and read the tute on FLVPlayback Component Behaviors and learned a few things. I discovered with FLVPlayback I can load up to 7 files and loop them and it works. That's great, because that would let me make extended animation loops. It's pretty cool code and the tue is here: http://www.macromedia.com/devnet/flash/ ... print.html

And the code:
Code: [ Select ]
import mx.video.*;
var listenerObject2:Object = new Object();
listenerObject2.stateChange = function(eventObject:Object):Void {
  trace(my_FLVPlybk.state);
};
my_FLVPlybk.addEventListener("stateChange", listenerObject2);
my_FLVPlybk.contentPath = "cuepointloop12.flv";
    // Set Videos Behavior
    
    // Create a videos object to hold a video
    // playlist and event handler functions...
    var videos:Object = new Object();
    
    // Set up to 7 video feeds in a single component
    videos.list = new Array();
    videos.list[0] = "cuepointloop12.flv";
    videos.list[1] = "";
    videos.list[2] = "";
    videos.list[3] = "";
    videos.list[4] = "";
    videos.list[5] = "";
    videos.list[6] = "";
    videos.loop = true;
    videos.length = 1;
    videos.loaded = false;
    
    
    // Path to FLVPlayback components
    var m = this.my_FLVPlybk;
    
    // Set the path of the first video feed
    m.contentPath = videos.list[0];
    
    // Set a 'ready' event handler to load the videos
    videos.ready = function( evt:Object ):Void
    {
        if(!this.loaded){
            this.loaded = true;
            for( var n=1; n<this.list.length; n++ ){
                if( videos.list[n].indexOf(".flv") != -1 ){
                    m.activeVideoPlayerIndex = n;
                    m.contentPath = videos.list[n];
                    this.length++;
                }
            }
            m.activeVideoPlayerIndex = 0;
        }
    }
    m.addEventListener("ready",videos);
    
    // Set a 'complete' event handler to load the next video
    videos.complete = function( evt:Object ):Void
    {
        
        var nextIndex = Number(evt.vp)+1;
        if( nextIndex == this.length){
            if( this.loop ){
                nextIndex = 0;
            }else{
                return;
            }
        }
        m.activeVideoPlayerIndex = nextIndex;
        m.visibleVideoPlayerIndex = nextIndex;
        m.play();
    }
    m.addEventListener("complete",videos);
    
    // End Set Videos Behavior
            
  1. import mx.video.*;
  2. var listenerObject2:Object = new Object();
  3. listenerObject2.stateChange = function(eventObject:Object):Void {
  4.   trace(my_FLVPlybk.state);
  5. };
  6. my_FLVPlybk.addEventListener("stateChange", listenerObject2);
  7. my_FLVPlybk.contentPath = "cuepointloop12.flv";
  8.     // Set Videos Behavior
  9.     
  10.     // Create a videos object to hold a video
  11.     // playlist and event handler functions...
  12.     var videos:Object = new Object();
  13.     
  14.     // Set up to 7 video feeds in a single component
  15.     videos.list = new Array();
  16.     videos.list[0] = "cuepointloop12.flv";
  17.     videos.list[1] = "";
  18.     videos.list[2] = "";
  19.     videos.list[3] = "";
  20.     videos.list[4] = "";
  21.     videos.list[5] = "";
  22.     videos.list[6] = "";
  23.     videos.loop = true;
  24.     videos.length = 1;
  25.     videos.loaded = false;
  26.     
  27.     
  28.     // Path to FLVPlayback components
  29.     var m = this.my_FLVPlybk;
  30.     
  31.     // Set the path of the first video feed
  32.     m.contentPath = videos.list[0];
  33.     
  34.     // Set a 'ready' event handler to load the videos
  35.     videos.ready = function( evt:Object ):Void
  36.     {
  37.         if(!this.loaded){
  38.             this.loaded = true;
  39.             for( var n=1; n<this.list.length; n++ ){
  40.                 if( videos.list[n].indexOf(".flv") != -1 ){
  41.                     m.activeVideoPlayerIndex = n;
  42.                     m.contentPath = videos.list[n];
  43.                     this.length++;
  44.                 }
  45.             }
  46.             m.activeVideoPlayerIndex = 0;
  47.         }
  48.     }
  49.     m.addEventListener("ready",videos);
  50.     
  51.     // Set a 'complete' event handler to load the next video
  52.     videos.complete = function( evt:Object ):Void
  53.     {
  54.         
  55.         var nextIndex = Number(evt.vp)+1;
  56.         if( nextIndex == this.length){
  57.             if( this.loop ){
  58.                 nextIndex = 0;
  59.             }else{
  60.                 return;
  61.             }
  62.         }
  63.         m.activeVideoPlayerIndex = nextIndex;
  64.         m.visibleVideoPlayerIndex = nextIndex;
  65.         m.play();
  66.     }
  67.     m.addEventListener("complete",videos);
  68.     
  69.     // End Set Videos Behavior
  70.             


So I'm still not done with this, but I'm already liking that behavior extension.
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 23407
  • Loc: Woodbridge VA
  • Status: Offline

Post January 13th, 2006, 4:50 pm

btw - the second example works just fine as far as looping, but I still get that "hesitant glitch" when it loads the next movie or rewinds using "complete". That's what I want to elliminate.
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Joined: Jul 11, 2005
  • Posts: 1828
  • Loc: In the Great White North
  • Status: Offline

Post January 13th, 2006, 5:46 pm

So i've been playing with the FLVPlayback for the last week as well and I just had an interesting thought. Did you try the file off your local hard drive? and if so does it still lag at the end?

Here's my thought.

There's an option for buffer time and I'm wondering if the video caches in your browser might you be able to set the buffer to 0 or 0.01 seconds the second time you play the loop and therefore eliminate the pause that would be needed to cache the video?

I just ran into something similar off a cdrom drive and dumping the buffer seemed to help.
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post January 13th, 2006, 5:46 pm

Post Information

  • Total Posts in this topic: 18 posts
  • Users browsing this forum: No registered users and 22 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.