Media Playback
You can embed a media player into an ActiveX visualization element. Then you can play audio and video files on target systems or access a camera.
Linux x64/ARM (if supported by the device)
Windows (if overlay is active).
Use Cases
Streaming of video data from a camera (webcam, smartphone) to the target visualization
For example, an IP camera RTSP stream
Playing a video tutorial on a monitor
For example, a video tutorial "How to clean the filter on the machine"
Audible notification/alarm from a speaker
For example, a notification that the filter on a machine urgently needs to be changed. Or a warning about overheating, such as "The compartment will soon need to be refilled".
Setting up media playback
A CODESYS project which provides a visualization with a media player can be found at the following link.
Note
Sample project: "Media Player Example"
Structure | Property | Data Type | Value | Description |
|---|---|---|---|---|
Element Type |
| Visualization element | ||
Element |
| Name of the ActiveX component | ||
Cyclic calls → Method calls → Methods → [0] | Method |
| Returns the duration of the medium (in milliseconds) | |
Cyclic calls → Method calls → Methods → [0] → Call time | Variable |
| Variable for the update rate | |
Cyclic calls → Method calls → Methods → [0] → Result parameter | Variable |
|
| Variable for the duration of the medium (in milliseconds) |
[1] | Method |
| Gets the player position | |
[1] | Variable |
| ||
[1] | Variable |
|
| Variable for the player position |
[2] | Method |
| Method for determining the state | |
[2] | Variable |
| ||
[2] | Variable |
|
| Variable for the state |
[3] | Method |
| Gets the status of the media player | |
[3] | Variable |
| Call time | |
[3] | Variable |
|
| Variable for the status of the media player |
Conditional calls → Method calls Methods → [0] | Method |
| Starts the playback | |
Conditional calls → Method calls → Methods → [0] → Call condition | Variable |
|
| Variable which starts playback |
[1] | Method |
|
| Relative path or stream, such as NoteWhen using Qt5, a custom GStreamer pipeline is possible. This can be used for cameras with Video4Linux which are directly connected. |
[1] | Variable |
|
| Variable which triggers the assignment of the source |
[1] | Variable |
| URL | |
[2] | Method |
| Pauses the playback | |
[2] | Variable |
|
| Variable which triggers the pause |
[3] | Method |
| Stops the playback | |
[3] | Variable |
|
| Variable which triggers the stop |
[4] | Method |
| Sets the volume | |
[4] | Variable |
|
| Variable which triggers the change in volume |
[4] | Variable |
|
| Volume from 0 to 100 |
[5] | Method |
|
| Sets the playback rate |
[5] | Variable |
|
| Variable which triggers the setting of the playback rate |
[5] | Variable |
|
| Playback rate |
[6] | Method |
| Gets the playback position | |
[6] | Variable |
|
| Variable which triggers the query for the playback position |
[6] | Variable |
|
| Playback position |
[7] | Method |
| Gets the state | |
[7] | Variable |
|
| Variable which triggers the state query |
[7] | Variable |
| PLC_PRG.playerState | State |
[8] | Method |
| Activates the mirroring on the y-axis | |
[8] | Variable |
|
| Variable which triggers the mirroring on the y-axis |
[8] | Variable |
|
| Mirroring |
[9] | Method |
| Sets the position | |
[9] | Variable |
|
| Variable which triggers the setting of the position |
[9] | Variable |
|
| Position |
Playing a video file
To play a video file, you need to do the following:
Add the file to your project as an external file.
Specify the file name as the source.
The player searches relative to the
visuor on the PLC.