Skip navigation
Currently Being Moderated

Data Stream Playback Issue

Feb 5, 2014 4:57 PM

Tags: #problem #server #netstream #rtmp #stream #ams

Setup: AMS 5, AIR 3.9, Flex 4.6.0, Windows 7, Flash Builder 4.7


Issue: Given a stream that consists only of data (i.e. NetStream.send() calls), attempting to play it back "instantly" (i.e. with the "reset" value of 2 or 3 which streams all messages at once) doesn't work. It will play back the stream data, but is by no means "all at once," taking many seconds and taking longer as the stream size grows. The messages seem to be sent in bursts with periods of slow arrival reminiscent of normal replay speed.


Below is a simplified example that demonstrates this. When launched, it will send a message to the stream once a second for 30 seconds. Afterwards, buttons are activated that enable "instant" (i.e. reset of 3) replay of messages for the first 10/20/30 seconds of the stream. Watching the console output reveals that the replay is not "instant."


I have tried various workarounds with no success, including calling Stream.send() from the server instead. Changing NetStream.bufferTime seems to have no effect either. Also, a more comlex example of this functionality used to work with FMS 3.5, AIR 1, and Flex 3.1A, so something seems to have either have broken since then or changed such that this is no longer the correct way "instantly" play back a data stream.


I have tried to find other mentions of this issue but found nothing. Any help in understanding and/or working around this issue would be greatly appreciated. Thanks!



Client Code


<?xml version="1.0" encoding="utf-8"?>

<s:WindowedApplication xmlns:fx=""








            public function onActivate(event:Event):void


                _client.message = this.message;


                _timer.addEventListener(TimerEvent.TIMER, onTimer);

                _timer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete);


                _conn.client = _client;

                _conn.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);





            private function onNetStatus(event:NetStatusEvent):void




                    case "NetConnection.Connect.Success":

                        // begin publishing

                        _stream = new NetStream(_conn);

                        _stream.bufferTime = 5;

                        _stream.client = _client;

                        _stream.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);

                        _stream.publish("messages", "record");


                    case "NetStream.Publish.Start":

                        // start timer to actually publish for 30 seconds



                    case "NetStream.Unpublish.Success":

                        // publishing complete: enable playback

                        buttons.enabled = true;





            private function onTimer(event:TimerEvent):void


                _stream.send("message", _timer.currentCount);



            private function onTimerComplete(event:TimerEvent):void





            public function message(args:*):void


                trace("Call: message(" + args + ")");



            private function play(length:Number):void


      "messages", 0, length, 2);



            private var _conn:NetConnection                    = new NetConnection();

            private var _stream:NetStream                    = null;

            private var _client:Object                        = new Object;

            private var _timer:Timer                        = new Timer(1000, 30);





    <s:HGroup id="buttons" enabled="false">

        <s:Button label="10" click="play(10)"/>

        <s:Button label="20" click="play(20)"/>

        <s:Button label="30" click="play(30)"/>






Server Code (just accepts client connection)


application.onAppStart = function() {}


application.onAppStop = function(info)


    return true; //Garbage-collect this app



application.onConnect = function(client)





application.onDisconnect = function(client) {}


More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points