I am using the following code in a swf created with Flash CS6:
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
var customClient:Object = new Object();
ns.client = customClient;
ns.play("http://streamserver3.us:7018/stream?type=.flv");
It plays an Icecast audio streaming. How could I do to reconnect automatically (if the internet connection drops, etc.)?
Thank you very much for your help!
Sincerely.
See if any of these NetStreamInfo
options can help you detect a connection drop:
Try using a timer that fires every two seconds where the responding function checks if there has been a change (ie: amount of incoming data has become zero).
Maybe check with ns.info.dataBytesPerSecond
but explore the descriptions of other methods in that linked Info Class. Use an If
statement to check input has not become zero or Else
(if now zero) run your function that reconnects (does usual ns.stop();
& ns.play( url );
etc..).