Skip to main content
Known Participant
October 4, 2010
Question

NetStream events don't match up with video

  • October 4, 2010
  • 1 reply
  • 1021 views

I'm building a video player using NetStream, NetConnection, and backed by an FMS 3.5.3 server.  The NetStatus events from NetStream aren't always in sync with the actual video...  The worst one is that the stream will report NetStream.Play.Stop while the video's still playing.  How can I know when to toggle my pause button over to a play button and stop updating the ScrubBar when this event is premature?

If I let a video play through with no interference then Stop occurs at the right time.  If I ever seek to another place in the video before the video finishes, Stop will be wildly inaccurate.  Right now I've had to just have a timer fire constantly and I check to see if stream.time == lastStreamTime.  It's a nasty hack.

Advice?  Thanks

    This topic has been closed for replies.

    1 reply

    Participating Frequently
    October 5, 2010

    I do not think the messages are premature - its only that your buffer keeps in varying. So when you get Play.Stop your play has actually got stopped but there is still data in buffer which is yet to be played. Its same like when you set buffer of say 10 secs and start your play, you will get Play.Start but your video won't start playing till buffer is full. So its just analogous that after you get Play.Stop your video won't stop playing till your buffer gets empty.

    I would suggest following solution - after you get NetStream.Play.Stop , wait for NetStream.Buffer.Flush, so once you get this message - you are sure buffer is empty and your streaming has stopped. Hope this helps.

    tehxike1Author
    Known Participant
    October 7, 2010

    I'm not sure how to get the necessary info out of events to drive the UI.  If I'm playing the video and do a seek, I get:

    stream code: NetStream.Seek.Notify

    stream desc: Seeking 19000;client-inBufferSeek

    stream code: NetStream.Play.Start

    stream desc: undefined

    stream code: NetStream.Play.Stop

    stream desc: undefined

    stream code: NetStream.Buffer.Full

    stream desc: undefined

    stream code: NetStream.Buffer.Flush

    stream desc: undefined

    Keep in mind my video is still playing after it tells me Stop, Full, Flush.

    Participating Frequently
    October 13, 2010

    I might have to add to see if below helps :

    After you get NetStream.Buffer.Flush - wait for NetStream.Buffer.Empty - i am quite sure once you get that - video would have stopped playing.