Dropped connections can sometimes happen, and fortunately our pals at Adobe created a really simple and powerful feature in Flash Player Flash Player 10.1 that developers can take advantage of when creating their video players.  In this sample we show how this simple NetStream feature can allow you to keep a stream playing during a connection loss without disturbing the viewing experience of the user.  This will allow your custom script to resolve the connection on the back end without alerting the user.  Lets get started:

Assets Used:
Adobe Flash CS5
Flash Player 10.1+
Influxis Account
Adobe Flash Media Admin Console (Comes with FMS download)

Source Files:

Here is a quick Video Tutorial on how this works:

As a recap to the video, make sure you have the SAME video file in both accounts or application folders. Also make sure your code is setup using the play2() command for your NetStream:


ns = new NetStream(nc);
ns.client = this;
ns.inBufferSeek = true;
ns.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus );
ns.bufferTime = this.bufferTime;

//Initial Play - start off playing with this one.
var npo:NetStreamPlayOptions = new NetStreamPlayOptions();
npo.transition = NetStreamPlayTransitions.RESET;
npo.streamName = fileName;

//Resume Play - when connection is recovered use this to restart the playback w/o interruption.

ns.attach( this.nc );
//pass in the new net connection.
var npo:NetStreamPlayOptions = new NetStreamPlayOptions();
npo.transition = NetStreamPlayTransitions.RESUME;
npo.streamName = fileName;

This makes it very useful for a developer to handle connection drops, making applications much more intuitive and powerful.

Many Thanks to Brad Outlaw from Adobe for helping me out with this Post

6 Responses to “Uninterrupted Streaming with FMS and Flash Player 10.1”

  1. Arjun

    link to ReconnectSample.zip is not working.

    Please can you send me the ReconnectSample.zip to my email address.

    Thanks in Advance.

  2. George

    Have you gotten this to work in the case of “NetConnection.Connect.IdleTimeOut”? In my experiments, the “NetConnection.Connect.Closed” event that follows and idle timeout (10 minutes by default) destroys the Netstream object resulting in the error:

    Error: Error #2154: The NetStream Object is invalid. This may be due to a failed NetConnection.
    at flash.net::NetStream/play2()

    • Jerry

      @George No havent tested it yet but that error makes sense if you are not connected the netstream wont work. You can test recovery of that with this sample, just Download the Source Files above and add “NetConnection.Connect.IdleTimeOut” to the Main.as “onNetStatus” function as an addition to “NetConnection.Connect.Rejected” and “NetConnection.Connect.Failed” events it should recover to a new connection or the same if you specify it in the “failConPath” variable.

  3. Lorin Wiener

    ReconnectSample.zip link in this article (http://influxis.com/streaming-while-reconnecting-with-flash-player-10-1/) still does not work. Is the file still available?


Leave a Reply

Current day month ye@r *