Skip to content

Stream availability for playback

Sometimes it is necessary to check if stream is published on server before playing the stream. This can be done by one of the following ways

WebSDK function Stream.available()

Stream availability can be checked using WebSDK function Stream.available(). This function returns a promise that will be resolved if stream with the given name is published on server, and will be rejected if not. A special stream should be created to invoke the function, stream name to check and page element to display should be passed to Session.createStream() function. This special stream will automatically be destroyed after promise recolution or rejection,

Stream.available() usage example is available in Two Way Streaming application source code:

function availableStream(){
    var session = Flashphoner.getSessions()[0];
    var streamName = $('#playStream').val();
        name: streamName,
        display: remoteVideo
        $("#availableStatus").text("AVAILABLE").attr("class", "text-success");
    }, function(stream){
        $("#availableStatus").text("UNAVAILABLE").attr("class", "text-danger");

This method works in CDN, including transcoded streams, if stream name to check is passed with profile name. In this case promise can be rejected if stream is available on server, but is protected with ACL key.

REST API query /stream/find

If the first method cannot be used for some reason, stream availability on server can be checked with REST API query /stream/find. The request should be sent directly to the server stream supposed to be played from. If the stream with given name is published on this server, it will respond 200 OK:

POST /rest-api/stream/find HTTP/1.1
Content-Length: 40
Content-Type: application/json

HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: application/json;charset=UTF-8
Date: Tue, 28 Mar 2017 16:05:16 GMT


This method works only for streams already published on the requested server.