Loop Query Action

The Loop Query actions allow third-party applications to query the Player API about a player’s current playlist.

You can call the Player API with the Loop Query actions using one of the following methods:

    • remote_action: Exposes the now_playing or show_loop action via the command-line remote_action tool.
    • XML: Exposes the now_playing or show_loop action through simple XML commands sent to port 2324.
    • Flash: Flash applications can call the Player API via ActionScript and the now_playing or show_loop action.

An additional option for show_loop is depth, which controls how many future loop items will be reported.

You can query a player’s loops by invoking the standalone executable remote_action which ships with Broadsign Player. It can be found in the player’s installation bin directory.

For example, to query the items currently playing in each frame, type:

remote_action now_playing

To query all items in each frame, as well as all upcoming items in the loop, type:

remote_action show_loop

An additional option for show_loop is depth, which controls how many future loop items will be reported:

remote_action show_loop --depth 3

A custom application can query a player’s loops by sending an XML message to the monitor_remote port (2324). Use one of the following actions. Broadsign Player will reply with a short XML document:

    • now_playing: Retrieves the items currently playing in each frame.
    • show_loop: Retrieves the items currently playing in each frame, as well as all upcoming items until the end of the current loop.

To retrieve the items currently playing in each frame, send:

<rc version="1" id="1" action="now_playing" frame_id="0"/>\r\n\r\n

The player will respond with the following XML document:

<!DOCTYPE rc>
<rc status="1" id="1" version="1" action="now_playing">
 <frame id="1456804" loop_policy_id="1282483" geometry_type="percent" day_part_id="1456803" width="100" name="Fullscreen" height="100" x="0" y="0" z="0">
  <current_item slot_duration_ms="131518" remaining_ms="36893">
   <bundle trigger_category_id="0" id="2846715" loop_weight="0" allow_custom_duration="no" category_id="0" or_conditions="" loop_category_id="0" end_date="2020-01-07" position="1" name="PlayStation Experience 2015 Final Fantasy VII Remake - PSX 2015 Trailer _ PS4" max_duration_msec="131518" secondary_category_ids="" full_screen="yes" and_conditions="" not_conditions="" attributes="">
    <ad_copy id="2846708" original_filename="PlayStation Experience 2015 Final Fantasy VII Remake - PSX 2015 Trailer _ PS4.mp4" mime="mp4" name="PlayStation Experience 2015 Final Fantasy VII Remake - PSX 2015 Trailer _ PS4" flash_parameters="" feeds="" attributes="audio_codec=aac&#xa;duration=131518&#xa;height=720&#xa;video_codec=h264&#xa;volume_modifier=79&#xa;width=1280"/>
   </bundle>
  </current_item>
 </frame>
</rc>

To retrieve the items currently playing in each frame, as well as all upcoming items until the end of the current loop, send the following:

<rc version="1" id="1" action="show_loop" frame_id="0"/>

An additional option for show_loop is depth, which controls how many future loop items will be reported:

<rc version="1" id="1" action="show_loop" depth="3" frame_id="0"/>
Loop Query – XML Parameters
Parameter Description
version The version is always 1.
id Contains the identifier of the request.
action Required. The kind of action to be taken: either now_playing or show_loop.
depth Optional. Controls how many future loop items will be reported. No limit, but too many calls of too high a value can cause performance problems. If not specified, default is “3”.
frame_id Optional. The ID of the frame or frames on which the loop is playing.

Your interactive application can query a player’s loops via the WebSocket server of monitor_remote (port 2326). You will need to enable the WebSocket server. For more information, see Configuration Profiles – Players – The Remote Control Tab.

Use one of the following actions. The Broadsign Player will reply with a short JSON string:

    • now_playing: Retrieves the items currently playing in each frame.
    • show_loop: Retrieves the items currently playing in each frame, as well as all upcoming items until the end of the current loop.

To retrieve the items currently playing in each frame, send the following JSON string:

{
    "rc": {
        "version": "1",
        "id": "1",
        "action": "now_playing",
        "frame_id": "0"
    }
}

The player will respond with the following:

{
    "rc": {
        "frame": {
            "current_item": {
                "bundle": {
                    "ad_copy": {
                        "id": "2846708",
                        "original_filename": "PlayStation Experience 2015 Final Fantasy VII Remake - PSX 2015 Trailer _ PS4.mp4",
                        "mime": "mp4",
                        "name": "PlayStation Experience 2015 Final Fantasy VII Remake - PSX 2015 Trailer _ PS4",
                        "flash_parameters": "",
                        "feeds": "",
                        "attributes": "audio_codec=aac\nduration=131518\nheight=720\nvideo_codec=h264\nvolume_modifier=79\nwidth=1280"
                    },
                    "trigger_category_id": "0",
                    "id": "2846715",
                    "loop_weight": "0",
                    "allow_custom_duration": "no",
                    "category_id": "0",
                    "or_conditions": "",
                    "loop_category_id": "0",
                    "end_date": "2020-01-07",
                    "position": "1",
                    "name": "PlayStation Experience 2015 Final Fantasy VII Remake - PSX 2015 Trailer _ PS4",
                    "max_duration_msec": "131518",
                    "secondary_category_ids": "",
                    "full_screen": "yes",
                    "and_conditions": "",
                    "not_conditions": "",
                    "attributes": ""
                },
                "slot_duration_ms": "131518",
                "remaining_ms": "36893"
            },
            "id": "1456804",
            "loop_policy_id": "1282483",
            "geometry_type": "percent",
            "day_part_id": "1456803",
            "width": "100",
            "name": "Fullscreen",
            "height": "100",
            "x": "0",
            "y": "0",
            "z": "0"
        },
        "status": "1",
        "id": "1",
        "version": "1",
        "action": "now_playing"
    }
}

To retrieve the items currently playing in each frame, as well as all upcoming items until the end of the current loop, send the following:

{
    "rc": {
        "version": "1",
        "id": "1",
        "action": "show_loop",
        "frame_id": "0"
    }
}

An additional option for show_loop is depth, which controls how many future loop items will be reported:

{
    "rc": {
        "version": "1",
        "id": "1",
        "action": "show_loop",
        "depth": "3",
        "frame_id": "0"
    }
}
Loop Query API – JSON Parameters
Parameter Description
version The version is always 1.
id Contains the identifier of the request.
action Required. The kind of action to be taken: either now_playing or show_loop.
depth Optional. Controls how many future loop items will be reported. No limit, but too many calls of too high a value can cause performance problems. If not specified, default is “3”.
frame_id Optional. The ID of the frame or frames on which the loop is playing.
Sample Request Scripts

Loop Query – ActionScript 2.0 sample:

// Start ActionScript 2.0
var theSocket:XMLSocket = new XMLSocket();

theSocket.onConnect=function() {
  theSocket.send(new XML("<rc version=\"1\" id=\"1\" action=\"now_playing\"/>
    \r\n\r\n"));
}

theSocket.onXML=function(myXML) {
  // XXX: parse and use the returned XML here
  trace(myXML);
  theSocket.close();
}

theSocket.connect("localhost", 2324);

Loop Query – ActionScript 3.0 sample:

//Start ActionScript 3.0
import flash.net.Socket;
import flash.events.*;
var socket:Socket = new Socket();
socket.addEventListener(Event.CONNECT, onConnect);
socket.addEventListener(Event.CLOSE, onClose);
socket.addEventListener(IOErrorEvent.IO_ERROR, onError);
socket.addEventListener(ProgressEvent.SOCKET_DATA, onResponse);
socket.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecError);
socket.connect("127.0.0.1", 2324);

function onConnect(e:Event):void {
  socket.writeUTFBytes("<rc version=\"1\" id=\"1\" action=\"now_playing\">");
}

function onClose(e:Event):void {
  // Security error is thrown if this line is excluded
  socket.close();
}

function onError(e:IOErrorEvent):void {
  trace("IO Error: "+e);
}
function onSecError(e:SecurityErrorEvent):void {
  trace("Security Error: "+e);
}

function onResponse(e:ProgressEvent):void {
  if (socket.bytesAvailable>0) {
    var testxml: XML = new XML(socket.readUTFBytes(socket.bytesAvailable));
    trace(testxml.toString());
  }
}
Sample now_playing Return Script:

This return script provides information to identify the frame in which the content is interested, e.g., id, dimensions, loop_policy_id. Also, it outlines the properties of the current bundle and ad copy.

The tag provides the slot duration in milliseconds as well as how much time in ms is remaining before the item stops playing.

The current bundle and ad copy are repeated for each active frame.

<!--?xml version="1.0"?-->
<frame id="1234",
  name="Main Frame",
  loop_policy_id="234",
  day_part_id="345",
  x="0",
  y="0",
  z="1",
  width="1280",
  height="1024",
  screen_no="0",
  geometry_type="pixel">

  <current_item slot_duration_ms="30000", remaining_ms="12450">
    <bundle id="1234",
      name="Ice Age 1080p",
      max_duration_msec="30000",
      allow_custom_duration="yes",
      category_id="1234",
      loop_category_id="1234",
      trigger_category_id="1234",
      loop_weight="123",
      fullscreen="yes">
        <ad_copy id="1234"
          name="Ice Age 1080p",
          originalfilename="abc.mp4",
          mime="mp4",
          attributes="....",
          feeds="....",
          flash_parameters="...."/>
    </bundle>
  </current_item>

</frame>
Sample show_loop Return Script:
<!--?xml version="1.0"?-->
<frame id="1234",
  name="Main Frame",
  loop_policy_id="234",
  day_part_id="345",
  x="0",
  y="0",
  z="1",
  width="1280",
  height="1024",
  screen_no="0",
  geometry_type="pixel">

  <current_item slot_duration_ms="30000", remaining_ms="12450">
    <bundle id="1234",
        name="Ice Age 1080p",
        max_duration_msec="30000",
        allow_custom_duration="yes",
        category_id="1234",
        loop_category_id="1234",
        trigger_category_id="1234",
        loop_weight="123",
        fullscreen="yes">
      <ad_copy id="1234",
        originalfilename="abc.mp4",
        mime="mp4",
        attributes="....",
        feeds="....",
        flash_parameters="...."/>
    </bundle>
  </current_item>

  <next_item slot_duration_ms="30000" prebuffered="yes">
    <bundle id="1234",
        max_duration_msec="30000",
        allow_custom_duration="yes",
        category_id="1234",
        loop_category_id="1234",
        trigger_category_id="1234",
        loop_weight="123",
        fullscreen="yes">
      <ad_copy id="1234",
        name="Ice Age 1080p",
        originalfilename="abc.mp4",
        mime="mp4",
        attributes="....",
        feeds="....",
        flash_parameters="...."/>
    </bundle>
  </next_item>

</frame>