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

Seeking in NetStream with appendBytes

Guest
May 26, 2010 May 26, 2010

Copy link to clipboard

Copied

Hello,

i hope anyone can help me.

I  play a video over the NetStream.appendBytes() method.


If  I use the NetStream.seek() method the video stop and I get the NetStreamStatusEvent ""NetStream.Seek.Notify"

I have read in the documentation that the buffers is flushing. I have to call the NetStream.appendBytesAction(NetStreamAppendBytesAction) method

But after that nothing happend.

Any ideas?

Code:

     NetStream:

        ns = new NetStream(_netConnection);
        ns.bufferTime = _bufferTime;
        ns.addEventListener(NetStatusEvent.NET_STATUS, netStreamStatusHandler);
        ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
        var client:Object = new Object();
        client.onMetaData = metaDataObject;
        ns.client = client;
        ns.play(null);               
        ns.appendBytes(bytes);

      Seeking:

        ns.seek(seekPos);

     NetStreamStatus:

        case "NetStream.Seek.Notify" :
            trace("NetStream Notify");
            ns.appendBytesAction(NetStreamAppendBytesAction.RESET_SEEK);
            break;

Thx

Views

9.9K

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

correct answers 1 Correct answer

New Here , Nov 08, 2010 Nov 08, 2010

Are you writing any additional bytes to your stream after the seek?  As per the API Documentation, calling seek() in this mode (what Adobe refers to as "Data Generation Mode") flushes the stream's playout and FIFO buffers.  In essence, it discards any data previously written to the stream, and leaves you with a blank slate.  So really the use-case goes like:

//start playing

ns.play(null);               

ns.appendBytes(bytes);  //write the bytes to play from the beginning of the stream

//seek

ns.see

...

Votes

Translate

Translate
LEGEND ,
May 26, 2010 May 26, 2010

Copy link to clipboard

Copied

It may be better if you ask in the appropriate developers forum (Flash, Flex, ActionScript, ...?).

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
New Here ,
Sep 15, 2010 Sep 15, 2010

Copy link to clipboard

Copied

Hi,

I have exactly the same problem,

Did you manage to solve this problem yet?

thanks

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
New Here ,
Nov 03, 2010 Nov 03, 2010

Copy link to clipboard

Copied

Anybody has any luck with this issue?

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
New Here ,
Nov 08, 2010 Nov 08, 2010

Copy link to clipboard

Copied

Are you writing any additional bytes to your stream after the seek?  As per the API Documentation, calling seek() in this mode (what Adobe refers to as "Data Generation Mode") flushes the stream's playout and FIFO buffers.  In essence, it discards any data previously written to the stream, and leaves you with a blank slate.  So really the use-case goes like:

//start playing

ns.play(null);               

ns.appendBytes(bytes);  //write the bytes to play from the beginning of the stream

//seek

ns.seek(0);  //the parameter to seek() is irrelevant, as both the playout and FIFO buffers will be cleared

ns.appendBytesAction(NetStreamAppendBytesAction.RESET_SEEK);  //you can do this in NetStreamStatus if you want

ns.appendBytes(seekPosBytes);  //write the bytes to play from the desired stream position

...so basically there is no built-in way to seek over already appended data.  The idea is that you append data to the stream more-or-less in real-time, and to perform a seek you flush whatever is in the buffers and start appending data from the desired point.  Playback from the NetStream itself is always linear in this usage mode (i.e. it just plays whatever is written to it, in the order it is written, until told to stop), the only variable is what you pass to it via the appendBytes() calls.

Now if you think that's a bit confusing, I don't blame you.  I'd blame Adobe for having an API function that does completely different things depending upon which mode the NetStream is being used in.  I think it may have been more appropriate to have seek() throw an exception when called in Data Generation mode, and have a flush() method that performs the current functionality of clearing the playout and FIFO buffers.  But anyways, I digress.

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
Nov 09, 2010 Nov 09, 2010

Copy link to clipboard

Copied

thanks, it works!!!!!!!!

its necessary to append bytes beginning with an keyframe position after seek()

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
New Here ,
May 30, 2012 May 30, 2012

Copy link to clipboard

Copied

Do you have more code for this example ??

seekPosBytes = how get it ?

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
New Here ,
Jun 08, 2012 Jun 08, 2012

Copy link to clipboard

Copied

from the keyframes informations contained in the metadata

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
New Here ,
Jun 21, 2012 Jun 21, 2012

Copy link to clipboard

Copied

how do i get the keyframes info? I've been trying various ways but i cant seem to be able to make it work

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 28, 2012 Aug 28, 2012

Copy link to clipboard

Copied

I got it worked....My code is,

// onmetadata function get all timestamp and corresponding fileposition..

function onMetaData(infoObject:Object):void {

                                                  for (var propName:String in infoObject) {

                                                            if (propName == "keyframes")

                                                            {

                                                                           var kfObject:Object = infoObject[propName];

                                                                           var timeArr:Array          =          kfObject["times"];

                                                                           var byteArr:Array          =          kfObject["filepositions"];

                                                                      for(var i:int=0;i<timeArr.length;i++)

                                                                      {

                                                                                var tagPos:int                      = byteArr;//Read the tag size;

                                                                                var timestamp:Number = timeArr;//read the timestamp;

                                                                                tags.push({timestamp:timestamp,tagPos:tagPos});

                                                                      }

                                                            }

// onseek click get approximate timestamp and its fileposition

     protected function seek_click(seektime:Number):void

                              {

                                                  var cTime:Number          =          0;

                                                  var pTime:Number          =          0;

                                                  for (var i:int=1; i<tags.length; i++)

                                                  {

                                                            cTime  = tags.timestamp;

                                                            pTime          =          tags[i-1].timestamp;

                                                            if(pTime < seektime)

                                                            {

                                                                      if(seektime < cTime){

                                                                                seekPos                    =          tags[i-1].tagPos;

                                                                                stream.seek(pTime);

                                                                                break;

                                                                      }

                                                            }

                                                  }

                              }

/// append bytes on seekposition

     private function netStatusHandler(event:NetStatusEvent):void {

     switch (event.info.code) {

          case "NetStream.Seek.Notify" :

                                                            stream.appendBytesAction(NetStreamAppendBytesAction.RESET_SEEK);

                                                            totalByteArray.position = seekPos;

                                                            var bytes:ByteArray = new ByteArray();

                                                            totalByteArray.readBytes(bytes);

                                                            stream.appendBytes(bytes);

                                                            stream.resume();

                                                            break;

          }

}

after searching a lot i got this solution....just try..!!!!

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
New Here ,
Sep 30, 2012 Sep 30, 2012

Copy link to clipboard

Copied

Hi Krishnan,

I was trying this code on my flv file which has no keyframes. So, will it not work without keyframes. If yes, then, the above code not worked for me. May you help me out from it?

Thanks,

Saurabh

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
Nov 03, 2012 Nov 03, 2012

Copy link to clipboard

Copied

LATEST

Hi Saurabh,

Your solution is to inject MetaData keyframes into flv file.

Use some injector tool, fe. FLV MetaData Injector

http://www.buraks.com/flvmdi/

Good luck!

Fiodor

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