Need to show status of live stream on website

Does anyone know how I can show the status of a live stream on a website? Currently when you go to your website and click Watch live, you get a player box that just shows a spinner and nothing shows when there is not a live broadcast. I would like to detect the status of a live stream and put up a graphic or something to show it is not on. I am on a Windows box. Is there a way just do do an http call or something to determine this?

Thanks

Chris

Hi Chris,

This example returns all published live stream names, and can be modified to check one stream

package test;
import java.util.Iterator;
import java.util.List;
import com.wowza.wms.amf.*;
import com.wowza.wms.client.*;
import com.wowza.wms.module.*;
import com.wowza.wms.request.*;
public class ModuleGetLiveStreams extends ModuleBase {
	public void getLiveStreams(IClient client, RequestFunction function,
			AMFDataList params) {
		
		AMFDataObj streams = new AMFDataObj();
		
		List<String> list = client.getAppInstance().getPublishStreamNames();
		
		Iterator<String> iter = list.iterator();
		int i=0;
		while (iter.hasNext())
		{
			streams.put("stream_" + i++,iter.next());
		}
		sendResult(client, params, streams); 
	}
}

AS3 client-side:

var clientObj:Object = new Object();
clientObj.getLiveStreams = function(streams:Object):void
{
for (var streamName:String in data)
	{
		trace("\t"+prop+":\t"+streams[streamName]);
	}
});
netconnection.client = clientObj;
netconnection.connect("rtmp://[wowza-address]:1935/[app-name]");

Richard

If like me you can’t make heads nor tails of the post above, I found a kind of workaround using PHP. If you have enabled cupertino streaming, you can read the contents of the generated .m3u8 with file_get_contents()

Then, you can see some differences if the stream is actually active or not. I’m not sure it will be 100% the same for everyone, but in my case, an active stream will show resolution information, while a “dead” one will not. So, this is what I use:

		if (stristr(file_get_contents($streamurl), 'RESOLUTION')) {
			$status = 'active';
		} else {
			$status = 'inactive';
		}

The problem with this approach, it takes about 10 seconds to get a result. So if you have a bunch of channels and want to check them all at once, you’ll probably run into PHP timeout issues.

And yes, I know it’s pretty nasty, and may not work for everyone, but it’s the most direct way I could find for doing this :slight_smile: