Skip to main content

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.

. This is supported on the following platforms:
  • 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

0_Sample_Project Sample project: "Media Player Example"

Table 4. Cyclic calls to the media player

Structure

Property

Data Type

Value

Description

Element Type

ActiveX

Visualization element

Element

NativeControls.Mediaplayer

Name of the ActiveX component

Cyclic calls → Method calls → Methods → [0]

Method

NativeControls.Mediaplayer.getDuration

Returns the duration of the medium (in milliseconds)

Cyclic callsMethod callsMethods → [0] → Call time

Variable

PLC_PRG.tiUpdateRate

Variable for the update rate

Cyclic callsMethod callsMethods → [0] → Result parameter

Variable

ULINT

PLC_PRG.uiDuration

Variable for the duration of the medium (in milliseconds)

[1]

Method

NativeControls.Mediaplayer.getPosition

Gets the player position

[1]

Variable

PLC_PRG.tiUpdateRate

[1]

Variable

ULINT

PLC_PRG.uiPosition

Variable for the player position

[2]

Method

NativeControls.Mediaplayer.getState

Method for determining the state 

[2]

Variable

PLC_PRG.tiUpdateRate

[2]

Variable

ULINT

PLC_PRG.playerState

Variable for the state

[3]

Method

NativeControls.Mediaplayer.getMediaStatus

Gets the status of the media player

[3]

Variable

PLC_PRG.tiUpdateRate

Call time

[3]

Variable

INT

PLC_PRG.mediaStatus

Variable for the status of the media player



Table 5. Conditional calls to the media player

Conditional callsMethod calls Methods[0]

Method

NativeControls.Mediaplayer.play

Starts the playback

Conditional callsMethod callsMethods[0]Call condition

Variable

BOOL

PLC_PRG.xPlay

Variable which starts playback

[1]

Method

STRING

NativeControls.Mediaplayer.setSource

Relative path or stream, such as rtsp://

Note

When using Qt5, a custom GStreamer pipeline is possible. This can be used for cameras with Video4Linux which are directly connected.

[1]

Variable

BOOL

PLC_PRG.xSetSrc

Variable which triggers the assignment of the source

[1]

Variable

PLC_PRG.url

URL

[2]

Method

NativeControls.Mediaplayer.pause

Pauses the playback

[2]

Variable

BOOL

PLC_PRG.xPause

Variable which triggers the pause

[3]

Method

NativeControls.Mediaplayer.stop

Stops the playback

[3]

Variable

BOOL

PLC_PRG.xStop

Variable which triggers the stop

[4]

Method

NativeControls.Mediaplayer.setVolume

Sets the volume

[4]

Variable

BOOL

PLC_PRG.xSetVolume

Variable which triggers the change in volume

[4]

Variable

INT

PLC_PRG.volume

Volume from 0 to 100

[5]

Method

BOOL

NativeControls.Mediaplayer.setPlaybackRate

Sets the playback rate

[5]

Variable

BOOL

PLC_PRG.xSetPlaybackRate

Variable which triggers the setting of the playback rate

[5]

Variable

REAL

PLC_PRG.rPlaybackRate

Playback rate

[6]

Method

NativeControls.Mediaplayer.getPosition

Gets the playback position

[6]

Variable

BOOL

PLC_PRG.xGetPosition

Variable which triggers the query for the playback position

[6]

Variable

UINT

PLC_PRG.uiPosition

Playback position

[7]

Method

NativeControls.Mediaplayer.getState

Gets the state

[7]

Variable

BOOL

PLC_PRG.xGetPlayerState

Variable which triggers the state query

[7]

Variable

PlayerState

PLC_PRG.playerState

State

[8]

Method

NativeControls.Mediaplayer.setMirror

Activates the mirroring on the y-axis

[8]

Variable

BOOL

PLC_PRG.bMirror

Variable which triggers the mirroring on the y-axis

[8]

Variable

BOOL

PLC_PRG.bMirror

Mirroring

[9]

Method

NativeControls.Mediaplayer.setPosition

Sets the position

[9]

Variable

BOOL

PLC_PRG.xSetPosition

Variable which triggers the setting of the position

[9]

Variable

BOOL

PLC_PRG.newPosition

Position



Playing a video file

To play a video file, you need to do the following:

  1. Add the file to your project as an external file.

  2. Specify the file name as the source.

    The player searches relative to the visu or on the PLC.