Pausing a NetStream while publishing to allow buffer toempty

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

  1. #1

    Default Pausing a NetStream while publishing to allow buffer toempty

    I am having trouble with dialup users who are publishing webcam video using
    NetStream.publish(streamname, "record"). The video doesn't completely upload
    because there's a backlog of data in the buffer that gets tossed when they hit
    the Stop button in my app and the stream gets closed.

    I figured a workaround would be to pause the uploading stream and wait for the
    bufferLength to reach zero before closing the stream, but I can't figure out
    how to pause a publishing stream. NetStream.pause() doesn't seem to work.

    I'd appreciate any help. Thanks.

    pilahaka Guest

  2. Similar Questions and Discussions

    1. Preventing a NetStream.Buffer.Flush
      I need to buffer a large amount of (non-live) streaming content in the background while the user is distracted with something else. So far, the only...
    2. NetStream.Play.Stop/NetStream.Buffer.Flush calledprematurely
      So I've created a custom video interface (based on the one http://movielibrary.lynda.com/html/modPage.asp?ID=182 ) that hinges on the...
    3. NetStream Buffer Pause
      I have a progressive video file FLV which is dynamically loaded using AS NetStream function. Now I want to stop the buffering of the video after a...
    4. NetStream.Buffer.Flush
      Hi people, I am getting a status code of "NetStream.Buffer.Flush" This isn't documented anywhere. Can you explain the meaning of this status...
    5. NetStream.Buffer problem on RH9.0
      Hi... I am having a problem using fcs on linux... First, I've tryied on Debian(SUCKS), so, I read in somewhere that FCS should work better on Red...
  3. #2

    Default Re: Pausing a NetStream while publishing to allow bufferto empty

    I came up with another workaround, that's not very elegant and certainly not
    foolproof, but it works... mostly. I'd still appreciate any other ideas. So,
    for posterity, here' what I did.

    When the user clicks the Stop button, I calculate a kbps using the buffer and
    the stream time, in an effort to figure out a time in the future when all the
    video up to the point where they clicked stop <u>should</u> be uploaded:

    stopTime = ns.time + ((ns.bufferLength / ((ns.time - ns.bufferLength) /
    ns.time)) * 1.20); // 20% margin for error

    Since, I can't seem to pause the stream, I let it go and wait until
    NetStream.time = stopTime. In my tests it seems to work pretty well, but if
    the user's upload speed varies by too much, video will get cut off. It also
    runs the risk of recording too much and capturing embarassing moments. All in
    all, not good, but the best I could do.

    I'd still appreciate some help.

    pilahaka Guest

  4. #3

    Default Re: Pausing a NetStream while publishing to allow bufferto empty

    I was wrestling with the same problem. Here is the solution I used and it
    sounds like it might solve your problem.

    When the user hits Stop, use the code:

    function stopRecording() {
    recordStatus.text = "Paused";
    stopRecordingVid = true;
    record_ns.attachVideo(null);
    record_ns.attachAudio(null);

    delete user_mic;
    delete user_cam;
    }

    Then for the NetStream's onStatus event:

    record_ns.onStatus = function(infoObject:Object) {

    if(infoObject.code == "NetStream.Unpublish.Success"){
    playback();
    }

    if(infoObject.code == "NetStream.Buffer.Empty"){
    if(stopRecordingVid == true){
    record_ns.publish(false);
    record_ns.close();
    delete record_nc;
    }
    }

    Whatever you set the buffer to .... when it empties out, the onStatus event
    will be called and by catching this along with the boolean set by the Stop
    button ... the flash recorder will stop taking data, the buffer will be sent
    with the stream, and when the buffer empties out, have the onStatus event catch
    it and close the stream.

    Hope this helps!
    Brian



    }

    fromsir12 Guest

  5. #4

    Default Re: Pausing a NetStream while publishing to allow bufferto empty

    Thanks. Works like a charm.
    pilahaka Guest

  6. #5

    Default Pausing a NetStream while publishing to allow buffer to empty

    Hi,

    I'm using your solution - but my recorded video is a little bit shorter than expected...
    I made a timer witch stops the recording after 30 seconds. So after 30 seconds :
    ns.attachCamera(null);
    ns.attachAudio(null);
    then i'm waiting for the "NetStream.Buffer.Empty" event to close the NetStream
    I don't understand why my video lasts 29 seconds and not 30
    I would understand if the video was longer but why shorter ?
    andrzej 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