Now Playing Howto

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_key = "00000000000000000000000000000000"; 
$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_secret, true));
$arrAPI['signature'] = $sig;
$request = json_encode($arrAPI);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, ""); // Set the URL
curl_setopt($ch, CURLOPT_POST, true); // Perform a POST
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // If not set, curl prints output to the browser
curl_setopt($ch, CURLOPT_HEADER, false); // If set, curl returns headers as part of the data stream
curl_setopt($ch, CURLOPT_POSTFIELDS, array("json" => $request));

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // Turns off verification of the SSL certificate.
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Turns off verification of the SSL certificate.

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

$arrResponse = json_decode($response, true);

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'];        
        echo preg_replace("|sestore1/username/|", "", $current);
      } else {
    die("Error: API call failed. {$arrResponse['message']}");
} else {
  die('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>