What is a video control?

Our company's video AV control has two functions: playing video files and AV input. The video control's video playback function is often used for creative startup effects, or to play product operation guides, advertising demonstrations in public places, etc.
This section mainly introduces the following three points:
- Playing videos within the screen
- Playing videos from USB flash drives/SD cards
- Introduction to LUA API
Scope of application: IoT type
Video format:
- MP4 files
- H264 encoding
- Audio stream in MP3 or AAC format
- Maximum video resolution <1280*768
- Maximum frames < 30ps
- Maximum bitrate < 1400
Download link for related routines:
- "IoT-based Video Playback Application" (click to jump)
For the conversion process of videos, please refer to this tutorial: Video File Conversion Instructions
19.1 Introduction to Video Control Properties
Introduction to Video Control Properties, as shown in the figure below

Usage
Play video and AV input, AV input requires support from the hardware model being used
Video files
Videos loaded into the control are named using a combination of letters (a-z), numbers (0-9), and underscores (_), and do not support other characters
Audio stream
Enable and Disable. When disabled, there will be no sound when playing videos.
Auto Play.
"Yes" or "No". When selected as "Yes", the video file will automatically play upon switching to this page.
When Playback Ends.
The action to be executed when the video playback ends. Options include "Do Not Process", "Send Notification", and "Switch to Next Page".

Repeat Count.
The number of times to repeat playback. 0 indicates continuous repetition.
19.2 Playing In-Screen Video Files.
The screen for "Playing In-Screen Video Files" introduces relevant playback instructions.
Screen Configuration.
On the "Background Image" of the "Playing In-Screen Video Files" screen, import the corresponding artwork image and add one video control (control ID: 1) and three button controls for setting the video playback status, as shown below.

Attribute Configuration
Video AV Control
Set the video control purpose to "Play Video", add a video file, set "Audio Stream" to enabled, "Auto Play" to yes, "When Playback Ends" to send a notification, and "Repeat Count" to 0, as shown below

Button Control ID2 - Play
Add Button Control ID2 "Image when pressed", and check Crop; since switching to this screen automatically plays the video, set the initial state of Button Control ID2 to "pressed"; the button action style is "Set", as shown below

Set the "Play Button", "Pause/Resume Button", and "Stop Button" to be mutually exclusive, with the operation shown below

In the Command Assistant interface, select "Video AV Control" from the left navigation bar, set control ID2 in screen ID0 to play a looping video, and fill in the corresponding button's Command Assistant, as shown below

As shown above: The command format is EE B1 70 00 00 00 01 00 FF FC FF FF. This command is mainly used to control the playback of the video playback control, allowing you to set the corresponding video playback loop count and have the video play according to the settings. (Note: The video playback control must first set the video path. If the control has already loaded a video file, only the play video command needs to be sent. In any case, the path for setting the playback video must be sent first, followed by the play command)
| Frame Header | Configuration Command | Function Code - Video Playback | Screen ID | Control ID | Playback count | Frame end |
|---|---|---|---|---|---|---|
| EE | B1 | 70 | 00 00 | 00 01 | 00 | FF FC FF FF |
Button control ID3 - Pause/Resume
The attribute configuration of button control ID3 is similar to that of button control ID2. Set the initial state of button control ID3 to "Pop up", and fill it in the instruction assistant for the corresponding button as shown below

. As shown above: The instruction format is EE B1 72 00 00 00 01 FF FC FF FF. This instruction is mainly used to control the video "Pause/Resume". The instruction meaning is as follows
| Frame header | Configuration instruction | Function code - Video pause/resume | Screen ID | Control ID | Frame Tail |
|---|---|---|---|---|---|
| EE | B1 | 72 | 00 00 | 00 01 | FF FC FF FF |
Button Control ID4 - Stop
The property configuration of Button Control ID4 is similar to that of Button Control ID2. Set the initial state of Button Control ID4 to "Pop Up", and fill in the corresponding button's instruction assistant as shown below

As shown above: The instruction format is EE B1 71 00 00 00 01 FF FC FF FF. This instruction is mainly used to control the video to "Stop". The instruction meaning is as follows
| Frame Head | Configuration Instruction | Function Code - Video Stop | Screen ID | Control ID | Frame Tail |
|---|---|---|---|---|---|
| EE | B1 | 71 | 00 00 | 00 01 | FF FC FF FF |
19.3 Play Video from USB Flash Drive/SD Card
The steps for playing videos from an external USB flash drive/SD card are basically the same as those for playing internal videos on the screen. The difference is that playing videos from an external USB flash drive/SD card requires sending an instruction to set the video path first. The operation process is as follows:
- Add a video playback control to the project screen (refer to Section 19.2)
- Set the video path internally
- Send instructions to control video playback, pause/resume, and stop (refer to Section 19.2)
Set the video path internally
Set the SD card path
Set the video format for playing from an SD card, such as playing the 0001.mp4 file from the SD card, where the drive letter of the SD card is SD:/ and the path is 'SD:/0001.mp4'.

The instruction is as follows: EE B1 74 00 00 00 01 73 64 3A 2F 30 30 30 31 2E 6D 70 34 FF FC FF FF. This instruction is mainly used to control the video to "stop". The instruction meaning is as follows:
| Frame header | Configuration instruction | Function code - Set video playback path | Screen ID | Control ID | Path (SD:/0001.mp4) | Frame tail |
|---|---|---|---|---|---|---|
| EE | B1 | 74 | 00 00 | 00 01 | 73 64 3A 2F 30 30 30 31 2E 6D 70 34 | FF FC FF FF |
Set USB drive path
Set video format for playing from USB drive, such as playing the 0001.mp4 file from USB drive, where the drive letter of the USB drive is U:/ and the path is 'U:/0001.mp4'

As shown below: EE B1 74 00 00 00 01 75 73 62 3A 2F 74 65 73 74 2E 6D 70 34 FF FC FF FF. This command is mainly used to control the video to "stop". The command meaning is as follows
| Frame header | Configuration command | Function code - Set video playback path | Screen ID | Control ID | Path (SD:/0001.mp4) | Frame tail |
|---|---|---|---|---|---|---|
| EE | B1 | 74 | 00 00 | 00 01 | 75 73 62 3A 2F 74 65 73 74 2E 6D 70 34 | FF FC FF FF |
19.4 Introduction to LUA API
play_video(pathname,repeat)
Play video control on the current page, applicable to IoT type
- pathname is the video path
- repeat is the number of repetitions, 0 for unlimited repetitions,
play on-screen video
such as playing the "1.mp4" video under the on-screen Videos directory, with the on-screen drive letter being "a:/", as shown below
--用户通过触摸修改控件后,执行此回调函数
--点击按钮控件,修改文本控件、修改滑动条都会触发此事件
function on_control_notify(screen,control,value)
if screen == sc_main2
then
if control == 7 and value == 0
then
play_ video(‘a:/Videos/1.mp4’,0)
end
end
endPlay U-disk/SD card video
such as playing the "test.mp4" video under the U-disk/SD root directory. It is recommended to create a global variable to obtain the drive letter in the U-disk/SD card trigger callback, as shown below
local sd_dir = ''
local usb_dir = ''
--用户通过触摸修改控件后,执行此回调函数
--点击按钮控件,修改文本控件、修改滑动条都会触发此事件
function on_control_notify(screen,control,value)
if screen == sc_main2
then
-- 假设视频控件ID为1,视频控件开启通知后,播放完毕会触发控件回调函数
if control == 1 and value == 0
then
--do user logic
elseif control == 2 and value == 0 -- 按钮按下播发SD卡视频
then
play_video(sd_dir..'/'..'test.mp4', 0, 0, 480, 272)
elseif control == 3 and value == 0 -- 按钮按下播发U盘视频
then
play_video(usb_dir..'/'..'test.mp4', 0, 0, 480, 272)
end
end
end
-- 系统回调函数,插入SD卡自动回调
function on_sd_inserted(dir)
sd_dir = dir
end
-- 系统回调函数,插入SD卡自动回调
function on_sd_inserted(dir)
usb_dir = dir
endFor more information on traversing LUA script files, video control, looping playback, etc., please refer to "Playing SD Card Video Files" (click to jump)
stop_video()
to stop video playback
Leave a Reply