all groups > flash actionscript > october 2007 >
You're in the

flash actionscript

group:

Flash Video - Probs with NetStream.onMetaData



Re: Flash Video - Probs with NetStream.onMetaData David Stiller
10/22/2007 7:39:47 PM
flash actionscript: ewon15,

[quoted text, click to view]

There's an onMetaData event defined by the NetStream class. Is that the
one you're talking about?

[quoted text, click to view]

Does your FLV file have metadata in it?

[quoted text, click to view]

Hrrm. Well, I've not experience that before. What version of
ActionScript are you using? How have you been testing that the onMetaData
event isn't dispatched?


David Stiller
Co-author, Foundation Flash CS3 for Designers
http://tinyurl.com/2k29mj
"Luck is the residue of good design."

Flash Video - Probs with NetStream.onMetaData ewon15
10/22/2007 10:51:53 PM
So i have created a video player and have noticed something about the
onMetaData function. I have a path to the videos as a relative path to my .swf
file ( myPath = 'media/'; ) and when i test my movie, the onMetaData function
does not get called. However, when everything is online, or being pulled from
an absolute path ( myPath = 'http://www.mydomain.com/media'; ) it is called.

I was just curious as to why that is...?
Re: Flash Video - Probs with NetStream.onMetaData David Stiller
10/23/2007 2:28:10 PM
ewon15,

[quoted text, click to view]

No worries. :) It just makes a difference in regard to whatever
snippets or samples would be helpful to you.

[quoted text, click to view]

When the FLV file is encoded, it may or may not have additional
information -- the metadata -- embedded into it. MP3 files, for example,
mainly contain audio recordings, but they have the capability of also
containing metadata a such as copyright date, the recording artist's name,
etc. If your FLV has no metadata, then the NetStream.onMetaData event won't
be prompted to do anything.

[quoted text, click to view]

Sometimes it helps to trace more than just the value of a given object.
It's possible, for example, that the trace() is indeed putting content to
the Output panel, but maybe that content is an empty string.

[quoted text, click to view]

Aha. So your trace is "hello," which should certainly be visible in the
Output panel -- provided the FLV file has metadata. That's good. And
you're saying that everything works with absolute paths, but not relative
paths? That makes me wonder if the relative path is hitting the video file
at all. (Of course, it would presumably be obvious if not, because you
wouldn't see the video at all.)

A quick glance at your code doesn't reveal to me anything outright
wrong. Some of that code looks like it was suggested by one of my blog
articles, but I can't be sure of that. (I was going to refer you to my
blog, but I didn't want to send you on a wild goose chase, if you'd already
come from there.)

My general approach, when I run into something baffling like this, is to
isolate the problem area in a separate FLA, so I can study it without the
distraction of the rest of the code. Here's a quick snippet from the Help
docs, for example ...

var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);

ns.onMetaData = function(infoObject:Object) {
for (var propName:String in infoObject) {
trace(propName + " = " + infoObject[propName]);
}
};

ns.play("http://www.helpexamples.com/flash/video/water.flv");

Paste that into a new FLV, test the SWF, and see if you get output in
your Output panel. You should. Then save that new FLA into the same folder
as your existing work and change the absolute path of that Adobe file to the
absolute path of one of your own. See if the same sort of output appears in
your Output panel. It should. If it doesn't, that means your FLV doesn't
have metadata. If it does, remove the URL portion and see if it still works
locally for the same FLV (your FLV), but with a relative path.


David Stiller
Adobe Community Expert
Dev blog, http://www.quip.net/blog/
"Luck is the residue of good design."

Re: Flash Video - Probs with NetStream.onMetaData ewon15
10/23/2007 3:52:54 PM
well i'm using actionscript 2.0 ... i have not had a chance to dive into AS3.
I've taught my self most everything and so i probably don't know the best way
to do things...

I can't remember where i found a tutorial, i may have simply used the livedocs
for flash 8 and built from it... i'm not sure what you mean when you ask me if
there is metadata in my FLV...but the way i know the onMetaData method of the
NetStream class was not being dispatched was by the timer and scrubber i set
up...plus i put a trace in the method and it was not outputting anything...

here's the gist of my code:



//initialize variables
_global.filePath = ""; //file path
_global.flvPath = "media/";
_global.videos = []; //array for videos
_global.titles = []; //array for videos
_global.description = []; //array for videos
_global.count = 0; //the current video
_global.total = 0; //total number of videos
_global.scrub = _root.controls.loader.scrubber; //path to movie clip
_global.loadbar = _root.controls.loader.loadbar; //path to movie clip
_global.loaded = 0; //number of bytes loaded
_global.duration = 0; //duration of current video
_global.ratio = 0; //ratio of the width of load bar compared to the duration
of video
_global.id = 0; //identification for the interval

//func for loading in the xml doc
function loadInfo(myXML) {
total = myXML.firstChild.childNodes.length;
//loop through all of the video
for (i = 0; i < total; i++) {
videos[i] = myXML.firstChild.childNodes[i].attributes.file;
titles[i] = myXML.firstChild.childNodes[i].attributes.title;
description[i] = myXML.firstChild.childNodes[i].firstChild;
}
loadVid(0);
};

//int xml
xmlDoc = new XML();
xmlDoc.ignoreWhite = true;
xmlDoc.onLoad = function(sucess) {
if (sucess) {
loadInfo(xmlDoc);
}
};
xmlDoc.load(filePath + "video.xml");

//int net connection and net stream
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);

ns.onMetaData = function(evt) {
duration = evt.duration;
trace("hello");
id = setInterval(updateStatus, .25);
};

ns.onStatus = function(evt) {
if (this.time > 0 && this.time >= (duration - 0.5)){
//trace("Video Complete");
//delete this.onStatus;
}
};

function updateStatus() {
loaded = ns.bytesLoaded / ns.bytesTotal;
loadbar._xscale = loaded * 100;
ratio = (loadbar._width / duration);
_root.controls.timeLeft = formatTime(ns.time);
scrub._x = ns.time * ratio;
};

function loadVid(count){
myVideo.attachVideo(ns);
ns.play(flvPath + videos[count]);
ns.seek(0.01);
ns.pause();
vidTitle = titles[count];
vidDesc = description[count];
vidCount = (count+1) +"/"+ total;
};
Re: Flash Video - Probs with NetStream.onMetaData ewon15
10/23/2007 7:00:12 PM
I figured it out!

So, a little background ? I created this video player because a client of mine
wanted to take their hour long PowerPoint (with sound and video) and put it
online in Flash. I figured the best way to do this was to take the PowerPoint,
convert it into a video file and utilize Flash as the means of which to display
and control it online. Long story short, during this testing time, the videos I
downloaded offline had metadata already encrypted in them, the videos I made
did not have any metadata and therefore Flash could not determine the length,
etc. I will have to figure out how to add metadata...

With that said, have you ever converted PPT to video before? Is there a high
quality product out there that you would recommend? I used Wondershare
(http://www.sameshow.com/powerpoint-to-video.html?gclid=CPDgzfzth48CFR-BQAodXCl9
kA)
and had some success, though the quality is not quite up to par.

Thank you very much for all of your helpful comments. I greatly appreciate it.
AddThis Social Bookmark Button