Displaying the Currently Playing Video in your Channel

Sample PHP Code

Create the file now_playing.php on your webserver, and use the following example code to query the API for viewers to your ScaleEngine application. Just add your API keys, and your CDN number.

$api_secret "0000000000000000000000000000000000000000000000000000000000000000"

$arrAPI = array(
'api_key' => $api_key,
'cdn' => 500,
'command' => 'channel.nowplaying',
'app' => 'steftest-channel',
'stream' => 'channel4',
'timestamp' => time(),

$request json_encode($arrAPI);
$sig base64_encode(hash_hmac('sha256'$request$api_secrettrue));
$arrAPI['signature'] = $sig;
$request json_encode($arrAPI);

$ch curl_init();
curl_setopt($chCURLOPT_URL"https://api.scaleengine.net/stable/"); // Set the URL
curl_setopt($chCURLOPT_POSTtrue); // Perform a POST
curl_setopt($chCURLOPT_RETURNTRANSFERtrue); // If not set, curl prints output to the browser
curl_setopt($chCURLOPT_HEADERfalse); // If set, curl returns headers as part of the data stream
curl_setopt($chCURLOPT_POSTFIELDS, array("json" => $request));

curl_setopt($chCURLOPT_SSL_VERIFYHOSTfalse); // Turns off verification of the SSL certificate.
curl_setopt($chCURLOPT_SSL_VERIFYPEERfalse); // Turns off verification of the SSL certificate.

$response curl_exec($ch); //Execute the API Call
if (!$response) {
'Failed to connect to ScaleEngine API');
//echo $response;

$arrResponse json_decode($responsetrue);

if (
$arrResponse) {
  if (
$arrResponse['status'] == 'success') {
//the 'video' is the currently playing source, you probably want to edit this down to the file name
        //we plan to add a description field so you can show that
        //to see everything the API returns, do a var_dump       
        //we return 'previous' 'current' and 'next' - here, we show current        
$current $videos['current'];        
      } else {
"Error: API call failed. {$arrResponse['message']}");
} else {
'Unknown API Error');


Sample JQuery

Create the file now_playing.js on your webserver, and use the following example code to query the API every 60 seconds by calling the php script above.

        function now_playing() {
                url: '/now_playing.php',
                dataType: 'html',
                type: 'get',
                success: function(data) {
                    setTimeout( function(){ now_playing(); } ,60000);
function jqueryLoaded() {
        jQuery(document).ready(function() {

function checkJquery() {
    if (window.jQuery) {
    } else {
        window.setTimeout(checkJquery, 100);


Sample HTML

Finally, add a small div with span id that matches the ajax js function name (now_playing) to display the returned number from the API on your website and have it check in for updates every 60 seconds.

<div style="display: inline; width: 25px; color: #5588BB;"><span id="now_playing" style="text-align: center;"></span></div>
<script type="text/javascript" src="/now_playing.js"></script>