# Example of Sending Programs

# Basic Information

1、Programs are divide into vsn and materials.

    vsn is the playback format, which has detailed definitions. Materials are the content to be played. Devices play programs by processing vsn and materials.

2、Both materials and vsn have fixed naming conventions, and the device validates them based on the downloaded materials and their names.

    materials(F_FileMD5_FileSize):F_7B71FD64DF1285916F152A00A4C5EA45_51772492.mp4

    Program(ProgramName_FileMD5_FileSize):Playlist6388_0ee96d129f030ef89f01b9a83e9926de_1362.vsn

    File MD5 calculation method:

public String calcMD5(InputStream stream) throws IOException {
        return DigestUtils.md5DigestAsHex(stream).toUpperCase();
    }

3、Example of playing a program: Here, we only implement operations afterm confirming the command (operations before confirming the command are already implemented in the device’s connection to the server interface, not discussed here).

Flowchart for Sending Programs:

descript

# Example of an Update Program Command

After the terminal receives and confirms the command to update programs, it will call the Get Program List API.

{
    "id":54943,//Command confirmation ID
    "post":310390,//Terminal ID
     "author_url":"",
    "content":{
        "raw":"{\"program\":\"dirty\"}" //Get program
    },
    "karma":0 //Terminal screen execution method
}

# Get the Program List Sent to the Terminal

Basic Information

Path: /wp-json/wp/v2/programs

Method: GET

Description:

The terminal receives a list of programs from the server. This list includes both programs published directly to the terminal (via the update program command) and programs published through scheduling (via the schedule command).

The terminal can obtain the URL fo program materials from the response data, for example: "http://192.168.1.33:80/wp-json/wp/v2/media?parent=1453".

For programs published directly, the "modified" and "modifiedGmt" fields in the response data should be updated to the time of publication. The terminal will play the program with the latest modification time upon receiving the update program command.

For scheduled programs, these fields do not need to be updated.

The terminal will loop the program with the latest modification time. If a schedule exists, it will play the scheduled program during the designated time periods.

Request Parameter

Parameter Required Example Description
clt_type Yes terminal Fixed as ‘terminal’

Reponse data

Name Type Required Description
root object [] Yes Collection of programs
├─ id number Yes Program ID
├─ date string Yes Creation time
├─ date_gmt string Yes Creation time in GMT
├─ modified string Yes Modification time
├─ modified_gmt string Yes Modification time in GMT
├─ type string Yes Program type
├─ title object Yes Program name object
├─ rendered string Yes Program name
├─ _links object Yes Collection of interfaces for retrieving materials
├─ wp:attachment object [] Yes Program address object
├─ href string Yes Program address: The device makes requests based on this URL; demo: “/wp-json/wp/v2/media?parent=1453”.

Response Example

[
  {
    "id": 1451,
    "date": "2024-07-31 06:51:43",
    "date_gmt": "2024-07-31 06:51:43",
    "modified": "2024-08-02 07:47:58",
    "modified_gmt": "2024-08-02 07:47:58",
    "type": "program",
    "title": {
      "rendered": "Playlist2189"
    },
    "_links": {
      "wp:attachment": [
        {
          "href": "http://192.168.1.33:80/wp-json/wp/v2/media?parent=1451"
        }
      ]
    }
  },
  {
    "id": 1453,
    "date": "2024-07-31 08:14:37",
    "date_gmt": "2024-07-31 08:14:37",
    "modified": "2024-08-02 07:49:36",
    "modified_gmt": "2024-08-02 07:49:36",
    "type": "program",
    "title": {
      "rendered": "Playlist6388"
    },
    "_links": {
      "wp:attachment": [
        {
          "href": "http://192.168.1.33:80/wp-json/wp/v2/media?parent=1453"
        }
      ]
    }
  }
]

# Get Material List

Basic Information

Path: /wp-json/wp/v2/media

Method: GET

Description:

The url of this interface is included in the response of the API that enables publishing program list to terminal (root-> links-> attachmentUrls-> href).

The terminal calls this interface to retrieve and download the material files for a specific program.

Request Parameter

Parameter Required Example Description
parent Yes 1453 Specifies the material list for the desired program via the parent parameter.

Response Data

Name Type Required Description
root object [] Yes Collection
├─ attachment_filesize integer Yes Size of the material file in bytes
├─ source_url string Yes File naming format (fixed requirement): XXX_FileMD5_FileSize

Response Example

[
  {
    "attachment_filesize": 1362,
    "source_url": "http://192.168.1.33:80/wp-content/playList/xml/Playlist6388_0ee96d129f030ef89f01b9a83e9926de_1362.vsn"
  },
  {
    "attachment_filesize": 51772492,
    "source_url": "http://192.168.1.33:80/wp-content/Tus/uploads/68161619-9608-4f03-8759-c56c81654636/F_7B71FD64DF1285916F152A00A4C5EA45_51772492.mp4"
  }
]