Skip to main content
Participant
November 10, 2006
Question

Streaming Video trouble

  • November 10, 2006
  • 8 replies
  • 686 views
Hello all,

I have a fairly basic problem. I am attempting to stream a single FLV video file. The audio is all that I am able to get to play at this point. The video controls have no effect on the audio playback. Not many people seem to be having this problem from what I have read, so I am sure I am making a simple mistake, but I am stumped. Here is my code.

var my_nc:NetConnection = new NetConnection();
my_nc.connect("rtmp://server_IP/testapp/dyn/");
var my_ns:NetStream = new NetStream(my_nc);

myVideo.attachVideo(my_ns);
my_ns.play("testapp"); // When I add .flv to testapp, the audio stops working too
stop();

The FLV is named "testapp.FLV" The video playback compenent has the instance name of "myVideo." The FLV is in the applications folder under testapp/streams/dyn/. When I test the swf in flash, it outputs this message: "1000: Unable to make connection to server or to find FLV on server." However, when I go into the fms2_console, I can see the instance is activated, and the FLV is "playing live."

The samples all had a main.asc file in their apps folder. So I decided to try it as well.
I put main.asc in the testapp folder that contained the code: load( "components.asc" );
In the swf file, I had load("main.asc"); on the first line. I was guessing when I did this, but it had no effect anyway.

Does anyone have any ideas? Much appreciated...
    This topic has been closed for replies.

    8 replies

    Participant
    November 17, 2006
    Upon review of the "solution" to get the flvPlayback component to work, I am left utterly baffled. Every "answer leads to more questions. I am going in circles on live docs.

    I have tried to link to the XML file via content path as they have suggested. I have also put the main.asc into the application folder as they have suggested (unaltered since they don't really explain what to change). I fixed the XML file as well, because the sample code provided is incorrect as some of you will discover.

    If anyone has any luck in getting this to work, please post your methods. I think there are a lot of people out there who are lost in actionscript hell as I am.
    Participant
    November 17, 2006
    For those who want to use the FLVplayback component for streaming, click the following link:

    http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=d244749e
    November 17, 2006
    Ugh... the forum code is screwing with the actionscript. Let me see if I can fix that
    November 17, 2006
    No. For that you need the onMetaData method of the netStream class.

    The cuepoints are in a metadata property aptly named 'cuePoints'. To access them, try this (where ns is the variable name for your netstream):

    ns["onMetaData"] = function(obj){
    cuePoints = obj.cuePoints
    }

    Now, you have an actionscript object (named cuePoints) that contains the cuepoints. So, what you want to do is monitor the current position of the playhead (the netstream time), and pick out the proper cuepoint. Here's one approach

    currentTime = ns.time;
    ax = 0;
    for (ix in cuePoints) {
    if (cuePoints[ix].time != undefined) {
    bx = ax+1;
    if ((cuePoints[ax].time<=currentTime) && (cuePoints[bx].time>=currentTime)) {
    nowPoint = ax;
    if (nowPoint != currentCuePoint) {
    currentCuePoint = nowPoint;
    trace("Current cue point is "+nowPoint);
    }
    break;
    }
    ax++;
    }
    }
    };

    Now, set up an interval to check the current cuepoint every 200ms or so
    int = setInterval(this, "getCuePoint", 200);

    I'm sure there are other ways it can be done, but this has worked well for me.
    November 17, 2006
    No. For that you need the onMetaData method of the netStream class.

    The cuepoints are in a metadata property aptly named 'cuePoints'. To access them, try this (where ns is the variable name for your netstream):

    -- code removed, because my variable names didn't play nice with the forum tags. see below --

    Inspiring
    November 16, 2006
    Question about the Video Object:

    Is it possible to add event listeners to the Video Object to listen for cue points that are attached via actionscript? Or is this function only compatible with the component?

    Thanks!
    November 16, 2006
    Unfortunately, I don't have much advice on any of the prebuilt components that ship with Flash, as I don't use them. I found that using the components tends to get in the way of what I want to do (as does using anyone else's code), so I prefer to build my own.

    As I understand things, the flv playback component requires a specific function in your main.asc (I think the method name is getStreamLength). Basically, the component asks the server how long the stream is before it loads up. If the function is missing in your main.asc, that may be the culprit. Look at the FMS debug panel when using the component, and see if it spits out a method not found error. If it does, you found the problem.
    Participant
    November 16, 2006
    Thanks a lot for your comments.
    I'll look into the 'getStreamLength' Method in the the Main.asc file tomorrow.
    I think I've had enough for one day - This day!!! :o)

    Cheers,
    CoCo
    Participant
    November 10, 2006
    Jay,

    That worked. You are my hero...
    Participant
    November 10, 2006
    As a follow up question, do you happen to know why the flvPlayback component will not work for streaming FLV content. Or does it just not work how I had it set up?
    November 10, 2006
    Seems that your problem is that you're using the FLVPlayback component, where you should be using a video object.

    Create a new video object in your library, drag it onto the stage, and name it myVideo. Of course, you'll need to remove or rename the flvplayback you have on the stage now.
    Participant
    November 15, 2006
    Your response here had me bouncing off the walls in Joy!!!
    I've been trying to figure out why My stream was only playing the sound and not the video.
    Your post above with regards to using a Video Object instead of a FLVPlayback Component solve my issue perfectly.

    My question to you is - and this may be a very novice question:
    How do i apply an FLVPlayback skin to my video that I have finally figured out how to stream?
    It's driving me insane and I need to set this up for a demo next week.
    Any help would be much appreciated.

    Cheers,
    CoCo