• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

netstream seek during buffer flush

Guest
Jul 30, 2012 Jul 30, 2012

Copy link to clipboard

Copied

Hi folks,

Quick question... I am developing a simple AIR video player but I am having small issues with seeking while the buffer is being flushed.

I am listening to and tracing the NetStatusEvents, and I noticed that when the video begins to approach the end of the video the buffer starts to Flush (NetStream.Buffer.Flush).  But if I try to seek during this time, the Buffer Flush trace keeps firing, and most of the time if I continue to scrub (seek) the video while all the Flushes are being fired I end up getting a NetStream.Play.Stop event (which I have set to stop the video).

The only work around I can think of (and implemented) was to disable my scrubber once the NetStream.Buffer.Flush event has been fired.  But I thought I would check to see if any body else has seen such a thing?

TOPICS
ActionScript

Views

3.5K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 31, 2012 Jul 31, 2012

Copy link to clipboard

Copied

You might want to try enabling inBufferSeek:

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/NetStream.html#inBuffer...

It might retain a bit longer. Also shortening your overall buffer length will reduce this issue to that amount of time.

Lastly, if it's just a "get around it" issue you might consider adding a "flag" of some sort to tell yourself when those events fire off. Then when a NetStream.Buffer.Flush fires, you set the flag to true to let yourself know it's emptying. Then when the NetStream.Play.Stop is fired off, you simply check that flag and if it's true you know you're in a flush and can run a ns.play() to make sure it plays after the seek.

Just remember to reset that flag when the buffer starts to fill or you do a seek so the NetStream.Play.Stop functions as normal.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 31, 2012 Jul 31, 2012

Copy link to clipboard

Copied

Thanks Sinious,

I will give inBufferSeek a look.

I was looking at shortening the buffer, but the correct me if I am wrong... but after ready about setting buffer, is that it only appluies to videos from a URL.  I should have added that the video files I am working with are for local playback.

As a workaround I did have a listener for the NetStream.Buffer.Flush event, and disabled the scrubber bar upon that event, as the problem only occurs if seeking took place after that event (i.e seeking after NetStream.Buffer.Flush fired - would cause it to fires several times).   Most of the time it causes no problems, but if I test it by doing a large amount of seek requests in short succesion (again after NetStream.Buffer.Flush), suddent the NetStream.Play.Stop event gets fired (which I have a method for that event).

I will look into inBufferSeek to see if that helps.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 31, 2012 Jul 31, 2012

Copy link to clipboard

Copied

Code operates at gigaflop speed so as long as you have the right conditions setting the right flag at the right time you should be able to avoid the issue. A HUGE amount of code can be completed in just a seconds worth of time. It might even be worth using a timer to put a "hold" on interaction for a single second before the user can proceed, only after the buffer emptying process begins so you don't bother normal seeks.

Playing off the local filesystem renders the buffer size moot. You are getting events for it however. You may as well set the buffer time to 0 and perhaps the event will only fire at the completion of the video.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 31, 2012 Jul 31, 2012

Copy link to clipboard

Copied

Yeah, I think I am going to disable the scrubber bar after the Flush starts to avoid the issue (that seeking while the Flush is happening can sometimes result in a NetStream.Play.Stop event).

I tried setting the buffer size (ns.setBufferTime) but I get a warning "1061: Call to a possibly undefined method setBufferTime through a reference with static type flash.net:NetStream."  I have no idea as to why....mmmmm

I traced out the buffersize while playing... and it's mostly at 1.4 seconds.... till it starts to flush, which is about 1.5 seconds before the end of the video.  So I am thinking if I can set the buffer to zero (or .1 even) I would avoid the early Flush.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 31, 2012 Jul 31, 2012

Copy link to clipboard

Copied

It's just bufferTime:

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/NetStream.html#bufferTi...

The default is actually already 0.1. It mentions you can set it to 0 for live streaming content but playback off a desktop is pretty much the same, so I'd probably set it to 0 anyhow.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 31, 2012 Jul 31, 2012

Copy link to clipboard

Copied

Thanks again for you help..... my newbie status to AS3 is starting to show.... when I try ns.bufferTime(0); I get the error....

Severity and DescriptionPathResourceLocationCreation TimeId
1195: Attempted access of inaccessible method bufferTime through a reference with static type flash.net:NetStream.Streamworks Audio Video Player/src/actionScriptactionScript.asline 241343765208891877

Like I say... newbie

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 01, 2012 Aug 01, 2012

Copy link to clipboard

Copied

bufferTime is a property of a NetStream object, like .x and .y are properties of a MovieClip. You set properties like so:

myNetStream.bufferTime = 0;

A method is a function and only then do you use your syntax with parenthesis around arguments. The error description mentions it's not a method (because it's a property).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 01, 2012 Aug 01, 2012

Copy link to clipboard

Copied

Doh!!!!

But it appears that hte buffer cannot be changed... still showing the same value for size even if I set it to 0.1

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 01, 2012 Aug 01, 2012

Copy link to clipboard

Copied

LATEST

If it were being downloaded it'd work but in your situation I think 1.5 seconds worth of "seek disable" time for the buffer to empty isn't so bad .

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines