Skip to content

ViSi-Genie: Play Video

Description

This Application Note explores the possibilities provided by ViSi-Genie for the Movie object:

  • Play
  • Pause
  • Stop
  • Change volume

This application note requires:

  • Workshop4 has been installed as discussed here;
  • The user is familiar with the Workshop4 environment and with the fundamentals of ViSi-Genie, as described in Workshop4 User Guide and ViSi-Genie User Guide;
  • When downloading an application note, a list of recommended application notes is shown. It is assumed that the user has read or has a working knowledge of the topics discussed in these recommended application notes

Note

Three ViSi-Genie projects are provided as examples to help you along this application note.

Downloadable Resources

The following are the sample project files for DIABLO-16 and PICASO.

PICASO DIABLO-16

Application Overview

Adding video to a graphical user interface increases the user experience dramatically. 4D Systems screens feature video playing.

The application discussed in this application note is a fully featured video player:

Video Player

Video Player

ViSi-Genie makes building such an application as simple as click-and-drop elements on the screen.

This application note describes how to add a Video object and how to customise it.

Setup Procedure

This application note comes with a zip file which contains two ViSi-Genie projects.

ViSi-Genie: projects

For instructions on how to launch Workshop4, how to open a ViSi-Genie project, and how to change the target display, kindly refer to the section Setup Procedure of the application note:

Create a New Project

For instructions on how to create a new ViSi-Genie project, please refer to the section Create a New Project of the application note

The Video Object

You can load the example project files under the Downloadable Resources section or follow the procedures described hereafter.

Select the Home menu to display the objects:

Home

The Video object is located on the System/Media pane:

System/Media pane

Add a Video Object

Click first on the video icon Video Icon and click on the WYSIWYG screen to place it.

The standard Windows Open file appears and asks for a video:

Open Window

Select the folder, here French Alps, and the picture, here MVI_0471 with a quiet creek in the Alps

MVI_0471

and press Open Open to load the video

The WYSIWYG screen now displays the video:

WYSIWYG screen

Notice that the video is square-shaped in the middle of the screen and that the proportions are not consistent with the original ones.

The Object Inspector displays the properties of the video object:

Object Inspector

The video object contains one single video.

Move the Video

To place the video on the top-right corner of the screen, first select the video object by clicking on it; red dots appear around the video:

WYSIWYG screen

Then, two options:

  • In the Object Inspector, modify the Left and Top properties:

    Left Property

    Top Property

  • Or use the mouse, click-and-drag the video on the top-left corner of the screen:

WYSIWYG screen

The WYSIWYG screen shows the new location of the video:

WYSIWYG screen

Resize the Video

To resize the video, first select the video object by clicking on it; red dots appear around the video:

WYSIWYG screen

Then, two options:

  • In the Object Inspector, modify the Height and Width properties:

    Height Property

    Width Property

  • Or use the mouse, click on the bottom-left red dots and resize the video to the desired dimension:

    WYSIWYG screen

The WYSIWYG screen shows the new size of the video:

WYSIWYG screen

The video can also be full-sized:

WYSIWYG screen

Because the screen used for this application note is 320 x 240, maximal height is 240 pixels and maximal width is 320 pixels. Those values may change depending on your specific screen. Please refer to the specification sheet of your screen.

Edit the Video

To edit the video, click on the video line in the Object Inspector:

Object Inspector

A Button symbol appears. Click on it.

A new window Image -- Video Converter appears and provides all the parameters for the video:

Image-Video Converter

On the left side, the input video; on the right, the output video.

Change the Video

You can load the example project files under the Downloadable Resources section or follow the procedures described hereafter.

To load a new video, click on Open

The standard Windows Open file appears and asks for a video:

Open Window

The Image -- Video Converter shows the new video:

Image-Video Converter

Note that all the settings have been changed.

This new video shows a toy car rolling from left to right.

Crop the Input Video

The left side provides all the information about the input video:

Image-Video Converter

Cropping part the input image is possible by editing Left, Top, Width and Height under Selection Window in Input by typing or clicking the up or down arrows Value Arrow

Image-Video Converter

Focusing on the car gives the following result:

Image-Video Converter

Only the image on the right is updated:

Image-Video Converter

Cropping the input image can also be done by changing the Height, Left, Top and Width properties under Source on the Object Inspector:

Object Inspector

Any format is possible, here's an unusual square.

Select a Sequence from the Video

Below the input video, there is a slider to select the frame. Here, frame 160 is selected and shown:

Image-Video Converter

On the example, the selected sequence on the video starts at frame 100 and ends at frame 220. There's no need to call for an external editor: just note the numbers of the first and last frames.

The image on the right is updated accordingly:

Image-Video Converter

The slider provides a convenient way to review the input video for selecting the sequence. Keep the numbers of the first and last frames of the sequence for later use.

Resize the Output Image

Similarly, the right side displays the output video:

Image-Video Converter

Because the screen used for this application note is 320 x 240, maximal height is 240 pixels and maximal width is 320 pixels. Those values may change depending on your specific screen. Please refer to the specification sheet of your screen.

Changing the size of the output image is possible by:

  • Resizing the video moving the red dotted rectangle,

  • Entering new values for Width and Height under Image | Actual Size | Output:

    Image-Video Converter

  • Clicking on the up or down arrows Value Arrows for the target value

Note

It is not possible to move the output image on the screen.

The top-left position of the video is defined by the Top and Left properties on the Object Inspector. Please refer to the Error! Reference source not found. section.

It is important to keep the ratio of the output video consistent with the input. The ratio corresponds to width/height. Is this example, input and output share the same width and height, at 200.

The output image is resized with an estimated size:

Image-Video Converter

The resulting screen would be:

WYSIWYG screen

However, most usual ratios are: 3/2, 4/3, 16/9.

Here, the example is updated with a standard 3/2-based screen:

Image-Video Converter

Define the Frame Delay of the Video

Last parameter, the frame delay defines how fast the frames are displayed. Normal speeds are between 25 and 30 images per second.

A speed of 25 images per second corresponds to a frame delay of 40 ms. A speed of 30 images per second corresponds to a frame delay of 30 1/3 ms. The higher the speed, the smaller the delay.

The frame delay has a direct impact on the size of the file: the shorter the delay, the bigger the file because more frames are required.

It may also have an impact on the quality of the rendering, as more frames require more power, especially in full screen mode. The screen used for this application note is 320 x 240, maximal height is 240 pixels and maximal width is 320 pixels, or a total of 76 800 pixels. Those values may change depending on your specific screen. Please refer to the specification sheet of your screen.

An example of a full screen video is provided under the Downloadable Resources section.

It is important that both the timer and the video have the same value:

  • Interval for the timer

    Interval

  • And Frame Delay for the video:

    Frame Delay

Confirm or Discard the Changes

When cropping, resizing are finished, click Ok to accept or Cancel to discard the changes.

Click on OK to accept the new image and settings and the WYSIWYG screen will now show the car:

WYSIWYG screen

Define the Sequence to Be Played

Using the slider on the Image -- Video Converter window, the interested sequence on the video starts at frame 100 and ends at frame 220.

To define the sequence, select the Frames on the Object Inspector

Object Inspector

display the details and update First and Last:

Frames

The video is now ready.

Control the Video Object

Building and uploading the project as it is now carry a surprise: the video doesn't play!

Add the Timer Object

Actually, another object is needed to play video: the Timer Timer object located under System/Media

System/Media pane

The Timer object raises an event at a given pace, for example every 1000 ms:

Object Inpector

The Interval can be changed easily, by editing the corresponding line, here with 40 ms:

Interval

Every 40 ms, Timer0 raises the event called OnTimer.

Now, the OnTimer event is defined to send the Video0NextFrame command to the Video0 object:

Object Inspector

The command Video0NextFrame stands for Tell the Video0 object to show the next frame of the video.

Video0NextFrame

So, every 40 ms, a new frame is going to be displayed. As a video is a succession of still images, changing the images quickly enough creates the impression of a movie.

It is important that both the timer and the video have the same value:

  • Interval for the timer

Interval

  • And Frame Delay for the video:

Frame Delay

Prepare the Buttons

Add five Button, a TrackBar, a Label and a CustomDigits objects to the form, customise their appearance properties as you like, in order to obtain the following screen:

Music player

Each object, among the buttons and the track-bar, when it is pressed and released, sends a specific command, directly or indirectly, to control the Video object.

Play the Video

To start playing the video, the WinButton1 button

Play

sends the command Timer0Play to Timer0:

WinButton1

The command Timer0Play stands for Tell the Timer0 object to start the timer and raise an event every defined delay.

The Timer0 timer Timer sends the Video0NextFrame to the Video0 object:

Timer0

The command Video0NextFrame stands for Tell the Video0 object to show the next frame of the video.

Summarising this indirect Play command gives:

WinButton1

Timer

It is important that both the timer and the video have the same value:

  • Interval for the timer

    Interval

  • And Frame Delay for the video:

    Frame Delay

Otherwise, the video may not played at normal speed!

Stop the Video

To stop or pause playing the track, the WinButton2 button

Stop

sends the command Timer0Stop to Timer0:

WinButton2

The command Timer0Stop stands for Tell the Timer0 object to stop the timer and no longer raise events.

So the Timer0 timer Timer stops and does nothing.

No more Video0NextFrame command is sent to the Video0 object, so the video stops.

Summarising this indirect Stop command gives:

Stop WinButton2

Timer0

Resume After Stop

To resume after Stop, just press Play again:

Play

The video resumes playing.

Show First Frame

To show the first frame, the Winbutton0 button

First

sends the command Video0First to Video0:

WinButton0

The command Video0Previous stands for Tell the Video0 object to show the previous frame of the video.

Summarising this direct First command gives:

First WinButton0

Show Previous Frame

To show the previous frame, the Winbutton3 button

Previous

sends the command Video0Previous to Video0:

WinButton3

The command Video0Previous stands for Tell the Video0 object to show the previous frame of the video.

Summarising this direct Previous command gives:

Previous WinButton3

Show Next Frame

To show the next frame, the Winbutton4 button

Next

sends the command Video0Next to Video0:

WinButton4

The command Video0Next stands for Tell the Video0 object to show the next frame of the video.

Summarising this direct Next command gives:

Next WinButton5

Select the Frame

To select a specific frame, just move the slider on track-bar, the TrackBar0 object

TrackBar

raises the event OnChanging and sends the command Video0Set to Video0:

Trackbar0

The command Video0Set stands for Tell the Video0 object to display the frame which number specified by the value.

The TrackBar0 object needs to be set with the correct parameters:

Trackbar0

The MinValue and MaxValue of the TrackBar shall be defined as follow:

  • MinValue is equal to 0 or the first frame to be displayed:

    Max/Minvalue

  • MaxValue corresponds to the duration of the selected sequence, and is equal to the total number of frames selected, here last 220 -- first 100 = 120:

Object Inspector

Summarising this command gives:

TrackBar0

Display the Frame Number

When OnChanged is raised, the Video0 object sends the command CustomDigits0Set

Video0

and CustomDigits0 displays the value:

CustomDigits0

Summarising this command gives:

Video0

Build and Upload the Project

For instructions on how to build and upload a ViSi-Genie project to the target display, please refer to the section Build and Upload the Project of the application note

The uLCD-32PTU and/or the uLCD-35DT display modules are commonly used as examples, but the procedure is the same for other displays

Summary

Timer

ViSi-Genie Command Comment
Timer Object Inspector Timer object sends Video0NextFrame command to Video object

Buttons

Element ViSi-Genie Command Comment
Play Resume Play WinButton1 Simple WinButton object sends the command Timer0Play to Timer object. Timer object is linked to Video object by Video0NextFrame command
Stop Stop WinButton2 Simple WinButton object sends the command Timer0Stop to Timer object. Timer object is linked to Video object by Video0NextFrame command
First First WinButton0 Simple WinButton object sends the command Video0First to Video object
Previous Previous WinButton3 Simple WinButton object sends the command Video0Previous to Video object
Next Next WinButton4 Simple WinButton object sends the command Video0Next to Video object

Frames

Element ViSi-Genie Command Comment
Select the frame TrackBar TrackBar0 TrackBar object sends the command Video0Set to Video object
Display frame number Video Video0 Video object sends the command CustomDigits0Set to CustomDigits object