Jump to content
Search Community

VideoLoader, MetaData, and Cuepoints

junky test
Moderator Tag

Recommended Posts

var video:VideoLoader = new VideoLoader("video.f4v", {name:"myVideo", container:this, width:stage.stageWidth, height:stage.stageHeight, scaleMode:"proportionalOutside", bgColor:0x000000, autoPlay:true, volume:1, requireWithRoot:this.root});

//start loading
video.load();
video.addEventListener(LoaderEvent.INIT, VIDEO_INIT);
function VIDEO_INIT(event:Event):void {
	trace(event.target)
}

 

What am I missing here?

Link to comment
Share on other sites

This isn't really VideoLoader-related exactly, but Flash makes those available in the NetStream's metaData (which VideoLoader records as its own metaData property). So you could get the array AFTER the INIT event fires like:

 

myVideoLoader.metaData.cuePoints

 

Of course VideoLoader allows you to add/remove ActionScript-based cue points too, but I'm pretty sure you just wanted to know about the ones that are embedded in the video file itself.

Link to comment
Share on other sites

Thanks Jack. I appreciate the followup.

 

So here's a strange thing that happened. The code below works:

var video:VideoLoader = new VideoLoader(flashVars.v, {name:"myVideo", container:this, width:stage.stageWidth, height:stage.stageHeight, scaleMode:"proportionalOutside", bgColor:0x000000, autoPlay:true, volume:1, requireWithRoot:this.root, estimatedBytes:75000});

//start loading
video.load();
video.addEventListener(LoaderEvent.INIT, VIDEO_INIT);
function VIDEO_INIT(event:Event):void {

		trace(event.target.metaData)

		for (var n:int=0; n				var cp = event.target.metaData.cuePoints[n];
			trace('  '+cp.time+' "'+cp.name+'" ('+cp.type+')');

		}//end for

}

 

Which works, but the strange thing is when I opened it on another machine that uses a new version of green sock I get an error:

TypeError: Error #1010: A term is undefined and has no properties.

at MethodInfo-200()

at flash.events::EventDispatcher/dispatchEventFunction()

at flash.events::EventDispatcher/dispatchEvent()

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

 

 

 

 

 

This is the version of green sock that works:

CHANGE LOG : GREENSOCK TWEENING PLATFORM

----------------------------------------

 

2011-07-07

 

but the latest build doesn't. Am I doing something wrong?

Link to comment
Share on other sites

Very difficult to say without seeing the file(s) and publishing on my end. Can you send me a very simple set of files that demonstrates the issue?

 

Note that Adobe's NetStream class has some very odd behavior around metaData that can cause it to not show up at all in some cases, or show up late in others. I'd be curious to know if you waited for the onComplete (or at least 1-2 seconds after INIT dispatches) if the metaData was properly populated.

Link to comment
Share on other sites

Ah yes, this is caused by the fact that Adobe's NetStream fires its onMetaData multiple times in some scenarios, particularly with F4V files, and the first time doesn't contain the cuePoints array. I see no elegant way to work around this, particularly because the behavior is unpredictable, so VideoLoader can't know if it's going to get a 2nd onMetaData call or not, thus it isn't as though it can just ignore the first call. However, I just updated VideoLoader so that it dispatches its INIT event each time it gets metaData, so that could happen more than once. You can simply check the VideoLoader's metaData.cuePoints in your INIT handler, and only run your code if it finds one. With your particular example, the first INIT call has a null cuePoints but the 2nd one is populated. Again, this is NOT a problem with VideoLoader, but rather Adobe's NetStream class.

 

The reason the old version of VideoLoader worked for you is because it dispatched the INIT event twice too. I had altered that behavior along the way, thinking that it was more intuitive to only have it fire once, but I can see why it can be helpful to get it every time metaData is received (hence today's change).

 

So snag the latest version and implement the suggestion I made above and you should be golden.

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