How to use the video control (IoT type)?

freeFree Technical Resource

This content is free to read, suitable for basic learning and search traffic.

How to use the video control (IoT type)?

What is a video control?

How to use the video control (IoT type)?插图

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:

  1. Playing videos within the screen
  2. Playing videos from USB flash drives/SD cards
  3. 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

How to use the video control (IoT type)?插图1

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".

How to use the video control (IoT type)?插图2

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.

How to use the video control (IoT type)?插图3

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

How to use the video control (IoT type)?插图1
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

How to use the video control (IoT type)?插图4

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

How to use the video control (IoT type)?插图5

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

How to use the video control (IoT type)?插图6

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 HeaderConfiguration CommandFunction Code - Video PlaybackScreen IDControl IDPlayback countFrame end
EEB17000 0000 0100FF 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

How to use the video control (IoT type)?插图7

. 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 headerConfiguration instructionFunction code - Video pause/resumeScreen IDControl IDFrame Tail
EEB17200 0000 01FF 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

How to use the video control (IoT type)?插图8

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 HeadConfiguration InstructionFunction Code - Video StopScreen IDControl IDFrame Tail
EEB17100 0000 01FF 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:

  1. Add a video playback control to the project screen (refer to Section 19.2)
  2. Set the video path internally
  3. 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'.

How to use the video control (IoT type)?插图9

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 headerConfiguration instructionFunction code - Set video playback pathScreen IDControl IDPath (SD:/0001.mp4)Frame tail
EEB17400 0000 0173 64 3A 2F 30 30 30 31 2E 6D 70 34FF 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'

How to use the video control (IoT type)?插图10

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 headerConfiguration commandFunction code - Set video playback pathScreen IDControl IDPath (SD:/0001.mp4)Frame tail
EEB17400 0000 0175 73 62 3A 2F 74 65 73 74 2E 6D 70 34FF 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
end
Play 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 
end

For 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

Related Tags
Put this resource to use in a real project?

Go to the Tool Center for message parsing, CRC verification and device debugging, or submit your requirements for selection and integration advice.

Engineer Membership

Turn this article into actionable debugging resources

After activation, you can use advanced message parsing, resource pack downloads, code examples, engineering cases and priority technical support, suitable for real project delivery.

Unlimited Advanced Tools
Resource & Code Packs
Complete Engineering Case Library
Priority Technical Support

Leave a Reply

Your email address will not be published. Required fields are marked *.