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:
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