simple code help with streaming 1 file

Ask a Question related to Macromedia Flash Flashcom, Design and Development.

  1. #1

    Default simple code help with streaming 1 file

    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.

    IMSTAMU Guest

  2. Similar Questions and Discussions

    1. Simple Cookie code
      I'm doing a cookie exercises for my CF class. The exercise creates a cookie and checks whether you have visited the site before. Code: <cfif...
    2. My code (included) for streaming is broken...
      Hello, I've included everything I have, simple, but, it seems right to me, hehe. But, it isn't. I have an embedded video object and a single...
    3. Problems with simple FileSystemObject code
      Hi, haven't been on here for a while but used to help out with ASP queries, hoping for a bit of guidance myself! I've stripped down the code i'm...
    4. Seeking critique of simple file line numbering code.
      I realize that grep performs some of this same functionality, but I just wanted to create the tool on my own for the experience. To that end, I'm...
    5. C# Equivalent of VB.Net Code -- One line of code, simple
      Great idea, thanks. I only need something simple in order for my contact form to work correctly. It's nothing with a lot of overhead. Ron...
  3. #2

    Default Re: simple code help with streaming 1 file

    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.



    ahab_2001 Guest

  4. #3

    Default Re: simple code help with streaming 1 file

    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
    rtmp://dl35.tamu.edu/test/_definst_/motion

    morharro Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139