samedi 18 juin 2016

How to pause and restart a NetStream object?

I have a NetStream object, based upon the following code:

streamID = "mystreamkey";
videoURL = "rtmp://mystreamurl";

vid = new Video();

nc = new NetConnection();

nc.addEventListener(NetStatusEvent.NET_STATUS, onConnectionStatus);
nc.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
nc.client = { onBWDone: function():void{}, streamConnected: streamConnected, streamDisconnected: streamDisconnected };
nc.connect(videoURL);

...

metaListener = new Object();
metaListener.onMetaData = received_Meta;
netStreamObj.client = metaListener;

netStreamObj.play(streamID);
vid.attachNetStream(netStreamObj);
addChild(vid);

All this is working fine, and I can also use netStreamObj.pause() to pause the live stream.

But how do I restart it? netStreamObj.play() won't work - it requires one parameter, so then I wrote this:

netStreamObj.play(streamID);
vid.attachNetStream(netStreamObj);

But this isn't working either.

How do I restart the stream, so that it connects to the live stream it was previously connected to?

Aucun commentaire:

Enregistrer un commentaire