Jump to content
Search Community

VideoLoader playProgress throws errors

mikaL test
Moderator Tag

Recommended Posts

Hi,

 

I have a VideoLoader that I use to play videos, so that when changing between them (either because of user action or video completing) , I try to clean up everything before loading the next file. I remove all video playback event listeners, and then call VideoLoader.dispose(true).

 

Then, when the next video plays, I get a lot of these:

 

TypeError: Error #1009: Cannot access a property or method of a null object reference.

at com.greensock.loading::VideoLoader/get videoTime()

at com.greensock.loading::VideoLoader/_playProgressHandler()

 

So I looked through the gs code & found this:

 

 

override public function addEventListener(type:String, listener:Function, useCapture:Boolean=false, priority:int=0, useWeakReference:Boolean=false):void {
if (type == PLAY_PROGRESS) {
_dispatchPlayProgress = true;
}
super.addEventListener(type, listener, useCapture, priority, useWeakReference);
}

 

 

But there was nothing that would set _dispatchPlayProgress to false, so I added this:

 

override public function removeEventListener(type:String, listener:Function, useCapture:Boolean=false):void {
if (type == PLAY_PROGRESS) {
_dispatchPlayProgress = false;
}
super.removeEventListener(type, listener, useCapture);
}

 

That seemed to solve the problem - but I'm still not sure if that actually was the problem, or was it maybe my clean up code.

 

Another problem I have is that sometimes PLAY_PROGRESS doesn't happen at all, or there are long periods (~10 sec) that it doesn't. The video still plays just as usual.

 

 

Mika

Link to comment
Share on other sites

It shouldn't be necessary to set _dispatchPlayProgress to false again. In fact, the code you added would break things if more than one PLAY_PROGRESS listener was added.

 

The behavior you're describing almost sounds like you must be trying to call a method (like maybe gotoVideoTime()) AFTER you disposed the VideoLoader (and of course you shouldn't do that).

 

Are you absolutely sure that you're not trying to call any methods or properties of the VideoLoader AFTER you dispose() it?

 

As for it not dispatching PLAY_PROGRESS for long periods of time, could you post a very simple example FLA that demonstrates that behavior? We just need to publish it on our end and add trace() statements, etc. to see what's happening.

 

Side note: please make sure you're using the latest version of LoaderMax/VideoLoader.

Link to comment
Share on other sites

  • 2 months later...

Hi again,

 

Back to this issue after a long time.

 

I still have no clue how I could be calling anything after disposing the video. I do something like

 

video.dispose(true);

video = null;

 

...and then everywhere when I call a method of the video I check

 

if (video)

. . . 

 

Wouldn't I see something else on the call stack when the erro is thrown too, not just the 2 lines?

 

Mika

Link to comment
Share on other sites

You could try adding a trace() statement inside any methods you suspect could get called inside VideoLoader (like gotoVideoTime()) and see if they get called right before the error. If you're still having trouble, please post a very simplified example FLA that we can publish on our end to see the error. (don't forget to zip it first, and please don't send complex production files - just a separate, simplified example is best)

Link to comment
Share on other sites

I tried all that, even removing every possible call (get videoTime etc.) to the videoLoader, but only removing

 

addEventListener(VideoLoader.PLAY_PROGRESS, onPlayProgress);

 

got rid of the errors, even when the handler contained no code. I suspected there was something with my cleanup code since I really don't understand all the dispose nuances, so I changed (_videoDisplay is a ContentDisplay)

 

_videoDisplay.dispose(true, true);

 

to 

 

_videoDisplay.dispose(true, false);

 

... problem solved.

 

 

Mika

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...