Jump to content
Search Community

VideoLoader throws 'null object ref' error

ggritmon test
Moderator Tag

Recommended Posts

After loading a series of assets of varying types, I construct a GreensockVid instance (my own class) for each VideoLoader & add them all to a VideoManager instance.

 

Unfortunately, when starting a GreensockVid, I get the following error:

 

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.greensock.loading::VideoLoader/set volume()
at com.greensock.loading::VideoLoader/set videoPaused()
at com.greensock.loading::VideoLoader/playVideo()
at com.h5g.video::GreensockVid/start()
...

 

The VideoLoader instance is added to the video manager as soon as its onChildComplete fires:

this._videoManager.addItem(new GreensockVid(targetVid), targetVid.name);

 

My video start method is pretty straight forward:

public function start():void 
{
	this._vidLoader.playVideo();
	this._vidLoader.rawContent.attachNetStream(this._vidLoader.netStream);
}

 

I'm not sure what's causing this problem. I was wondering if maybe the VideoLoader is automatically disposing of it's properties when it's only reference is the instance within the GreensockVid?

Link to comment
Share on other sites

It sounds like you must have disposed your VideoLoader instance and then tried playing it again at some point. Don't do that :) Once it is disposed, you cannot resurrect it - you'd need to create a new instance.

 

By the way - why are you manually attaching the NetStream to the rawContent?

 

Oh, and you are using the latest version of LoaderMax/VideoLoader, right?

Link to comment
Share on other sites

Please post a very simple example FLA that clearly demonstrates the issue so that we can publish it on our end and see what's going on. Include the support files too of course. Don't forget to zip them before posting here (or just post them on your server and put a link here to download the zip). It definitely sounds like there's something else going on in your code that's causing the issue but I can't tell for sure without seeing things in context.

Link to comment
Share on other sites

Unfortunately, very simple sample FLAs aren't reproducing the error. I don't have the time to pinpoint the exact cause, but I will continue to report my findings & see if anything raises a red flag.

 

When the VideoLoader child is reported complete, the _sound & _ns values exist.

 

When the XML finishes loading all its children & is itself loaded completely, I am seeing _dump() and _refreshNetStream() both get called. Unfortunately, after this point _ns & _sound no longer exist.

 

I've tried this with both flv & f4v files & get the same result.

Link to comment
Share on other sites

I figured out the issue. I have an AssetManager class which sorts the loaded elements into various other managers (VideoManager, XMLManager, etc). To garbage collect, I dispose(true) and unload() any loaders which I no longer need after filing their content, like XMLLoader. For obvious reasons, I must keep VideoLoaders around since they contain the API for video playback.

 

The problem was that when the main assets.xml was complete, the garbage collector called dispose(true) and unload()...which (I guess) does so on all the Loader children as well (ie: everything, including videos).

 

As a result, the videoLoaders were dumped and their properties null.

 

I added a conditional which says not to dispose() of any XMLLoaders which contain children. Does that seem like the best approach?

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...