Groups | Blog | Home
all groups > macromedia flash flashcom > december 2006 >

macromedia flash flashcom : simple code help with streaming 1 file



IMSTAMU
12/15/2006 5:22:12 PM
I set up the Flash Media Server 2.0 on Windows (test box) under the host
dl35.tamu.edu (behind a firewall so I don't mind giving it out)
Under the applications directory I create a directory called test
Under this directory I place a flash movie called motion.flv
In this same directory I copy the main.asc that comes with the Flash 8 software
I load the "test" application and use _definst_ as the instance name

In Flash Professional 8 I create a new fla called test.fla
I embed a movie and use the ClearOverAll.swf as the skin for the movie.
Under the Paramaters Tab I edit the content path to point to
rtmp:"//dl35.tamu.edu/test/_definst_/motion.flv
I test produce the html code and indeed the server shows a connection even
though nothing is playing.

Here is probably where I am most confused but I might have done something
wrong with the above as well. I am not a Flash programmer, I am a network guy.
All I want to do is the bare minimum in the simplest form of streaming. I
could not find code samples that worked including the tutorial on the Adobe
site (seems to be fairly common). Digging through other examples I "believe" I
found what I wanted but apparantly I did not implement it correctly or it is
not what I need after all and I would like someone to verify. The below is the
action script that I found that I placed within the test.fla. Is this wrong to
do?

nc = new NetConnection();
nc.connect("rtmp://dl35.tamu.edu/test/_definst_");

ns = new NetStream(nc);
my_video.attachVideo(ns);
ns.setBufferTime(0);
ns.play("test");

Is the above correct? Given the names I have told you, what should be
changed. Also does this even need to go here? Is it supposed to be in an
action script file all by itself? At any rate when producing this to html
there are several errors:

**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 16: Statement must appear
within on/onClipEvent handler
nc = new NetConnection();

**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 17: Statement must appear
within on/onClipEvent handler
nc.connect("rtmp://dl35.tamu.edu/test/_definst_");

**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 19: Statement must appear
within on/onClipEvent handler
ns = new NetStream(nc);

**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 20: Statement must appear
within on/onClipEvent handler
my_video.attachVideo(ns);

**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 21: Statement must appear
within on/onClipEvent handler
ns.setBufferTime(0);

**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 22: Statement must appear
within on/onClipEvent handler
ns.play("test");

Total ActionScript Errors: 6 Reported Errors: 6

Goal: All I want to do is stream 1 file.. just 1. I have no way of knowing
whether this server works before taking this simple step. It would be nice is
Adobe delivered out of the box streaming samples like all of the other
streaming servers we support do. But I digress. Any help is will be
appreciated beyond any means that I can appropriately convey including a sample
code package that works that I can just change a few lines in so I can
understand what is happening.
ahab_2001
12/15/2006 10:51:59 PM
Imstamu, I'm relatively new to this myself, but I did notice a few items in
your message that I wanted to comment on. First, the error messages you're
coming up with may be the result of putting the actionscript in the video
object itself, rather than in the timeline for the main SWF movie. What I
think you may want to do is put the actionscript in a layer called "Actions" in
the main timeline, select the keyframe for that layer in frame 1, and put the
actionscript in that keyframe. If you have put it in the video object (or in
some other object such as a button, etc.), you can get errors of the type you
are reporting (at least it has happened to me). However, as noted below, you
may not need that actionscript at all.

Second, you may want to try placing a directory under the "test" directory
called "streams", putting another directory called "_definst_" beneath the
"test" directory, and putting the FLV in the _definst_ directory. This is
where FMS is looking for the files to stream, as I understand it. (It sounds
from your description like you have placed the FLV directly below "test".)
Directly below test *is* the right place for main.asc, as you have done.
IMPORTANT: In terms of the path you use in the contentPath variable in the
video player object, the path for the directory actually holding the FLV should
*still* be rtmp://dl35.tamu.edu/test/_definst_/motion.flv, as you have done --
i.e., "streams" should not appear in the contentPath variable. Don't ask me
why, but this worked for me. The reason the server is showing a connection is
that you have put a "test" directory in the right place, and thus have
registered the application from the point of view of FMS, but you have not put
the FLV in the right place, and so FMS can't find the FLV file in the path
you've specified.

Third, are you using the FLVPlayback component in the swf file? (From the
fact that you're using one of the canned Flash skins, it sounds like that's the
case.) If so, and if you're just streaming one movie, you don't need to worry
about the code to open up a new net connection, new netstream, etc. -- all of
that is embedded in the FLVPlayback object. So all you need to do is put in
the RTMP path to the file -- rtmp://dl35.tamu.edu/test/_definst_/motion.flv --
in the contentPath variable for the FLVPlayback object; you do not need the
code opening the NetConnection and NetStream objects.

I hope this is useful. As noted, I am fairly new to this myself, but I have
been able to stream files successfully using FMS, FLV, and Flash.


morharro
12/16/2006 3:59:24 PM
From what I understand you do not need the .flv extension added to the content
path
rtmp://dl35.tamu.edu/test/_definst_/motion.flv, try this instead
[b]rtmp://dl35.tamu.edu/test/_definst_/motion[/b]
AddThis Social Bookmark Button