Actionscript: NetStream stutters after buffering.

Posted by meandmycode on Stack Overflow See other posts from Stack Overflow or by meandmycode
Published on 2009-07-03T15:54:08Z Indexed on 2010/04/13 10:43 UTC
Read the original article Hit count: 484

Filed under:
|
|
|

Using NetStream to stream content from http, I've noticed that esp with certain exported h264's, if the player encounters an empty buffer, it will stop and buffer to the requested length (as expected).

However once the buffer is full, the playback doesn't resume, but instead jumps ahead, as such- instantly playing the buffered duration in a brief moment, and thusly triggering an empty buffer again.. this will then continue over and over.

Presumably when the netstream pauses to buffer, the playhead position continues, and the player is attempting to snap to that position on resume- however given it could take 5 seconds to build a 2 second buffer- it ends up with a useless buffer again..

(this is an assumption)

I've attempted to work around this by listening for an empty buffer netstatus event, pausing the stream, and at the same time setting up a loop to check the current buffer length vs the requested buffer length.. and resuming once the buffer length is greater than or equal to the requested buffer.. however this causes problems when there isn't enough of the video remaining.. for example, a 10 second buffer with only 5 seconds remaining, the loop just sits there waiting for a buffer length of 10 seconds when theres only 5 left...

You would think that you could simply check which was smaller, the time left or the requested buffer length.. however the times flash gives are not accurate..

If you add the net streams current time index, plus the buffered time, the total is not the entire duration of the movie (when at the end).. it is close but not the same.

This brings me back to the original problem, and if there is another way to fix this, clearly flash knows when the buffer is ready, so how can i get flash pause when it buffers, and resume once the buffer is ready? currently it doesn't.. it pauses and then once the buffer is full- it plays the entire buffered content in about .1 of a second.

Thanks in advance, Stephen.

© Stack Overflow or respective owner

Related posts about actionscript-3

Related posts about flash