Skip to main content
Known Participant
July 4, 2010
Question

How to know when a playing video stream has anything to show?

  • July 4, 2010
  • 1 reply
  • 650 views

How can I tell after issuing a NetStream::play call when there is any video arrived which I can render (Video::attachNetStream)? I can see that most of that stuff is asynchronous and highly dependent on a number of variables like FMS latency, client latency and bandwidth, server load, weather etc. I however need a reliable dependent way of figuring when there is any picture to show. I administrate our service and need to monitor content people are publishing, for that I need to browse a hundre or so streams as fast as possible. What I do is I have a number of "player" streams that play a stream name (I use Administration API to get an array of these) , wait until there is picture, show it in a video object, disconnect video from stream, create new video object, play another stream, wait until picture, show it, and so on.

I found out that I can achieve a way to check whether video has arrived by NetStream::info.videoBufferByteLength, alternatively perhaps 'videoByteCount'. I cannot create a new stream for new video object, that is too much overhead, so I reuse streams. I close a stream, play new stream name, and wait until the either of the properties above is non zero. This has been working quite alright, but still occasionally I get stale data in the subsequent video objects, even when a stream is supposed to be playing new content. I need to avoid these.

So my question boils down to the already mentioned: what would be a reliable way to do what I am doing? It's just a stream of compressed data, there must be a way for Flash Player to know what is new data and what is stale data. In fact I don't think there is supposed to be stale data in a NetStream that is already playing something else!

I know this is hardcore stuff, but we are pushing it 🙂

    This topic has been closed for replies.

    1 reply

    Participating Frequently
    July 5, 2010

    Have you tried waiting for Buffer.Full message and then attaching. If not give it a try. What i mean is, when you issue NetStream.play - you will get sequence of messages like NetStream.Play.Start....so you wait for NetStream.Buffer.Full and then attach to videoobject - i think this will guarantee that you will have something to display when you attach.

    amnAuthor
    Known Participant
    July 8, 2010

    I tried a lot of things so far and there is still no reliable method to know when video is showing anything. Also, you should know that I don't get NetStream.Buffer.Full code AT ALL. But I do get image in the video, so that is not it. What is this code supposed to mean anyway? I am playing live video, and disabled the buffer altogether, I don't need it, because I only use the streaming data for snapshots.