<< Click to Display Table of Contents >> Navigation: Object Reference > Palette Objects > Multimedia Player |
Tutorial video about the Multimedia Player
Download this project to see a basic implementation of the Multimedia Player in a project.
The multimedia player is a complex object which contains other basic objects. Each basic object is registered in the player itself and takes a special function. The player represents a predefined construction kit which is fully customizable.
A media player can be placed on a frame and is used for playing audio or video files. As many other objects, the multimedia player has a lot of common properties. See here for a description. Only multimedia player specific properties will be described on this page.
Hint: The Multimedia Player object is only available for device panels with audio capabilities. Otherwise you won't see this object in the palette.
Please note:
If you want to use the MP4 formats in your project it is necessary that you purchase a license at https://www.mpegla.com/.
MP3 seems to be free of licenses as of now: https://www.iis.fraunhofer.de/en/ff/amm/consumer-electronics/mp3.html.
For MP4 you need to license “MPEG-4 Visual (Part 2)” and “AVC/H.264 (MPEG-4 Part 10)” in order to use both formats. If you only want to playback MP4 video files the H.264 license should be enough.
If in doubt, please contact the companies and ask for license assistance.
|
The following graphic shows the implemented state machine of the multimedia player object at runtime. |
The graphic below shows the default property states of the multimedia player object.
Fit To Frame SizeEnable this property to adapt the size of the multimedia player to the parent frame object.
Default value: Disabled Possible values: •Disabled: The Multimedia Player can be dynamically scaled to the desired size. •Enabled: The Multimedia Player will be scaled to the parent frame size. Auto Rearrange ControlsThis property activates / deactivates the internal layout manager of the multimedia player object. The manager takes care about the positioning and sizing of all included objects in design time. The layout manager has no effect at runtime. Resizing is only done when the object size is changed.
Default value: Enabled Possible values: •Disabled: The Multimedia Player objects will not be sized and positioned when changing the size of the Multimedia Player object. •Enabled: The Multimedia Player objects will be sized and positioned automatically when changing the size of the Multimedia Player object. Show DisplayThis feature removes the display container to use the multimedia player as a pure audio player or as a playback control bar:
Default value: Enabled Possible values: •Disabled: Removes the display container. •Enabled: Adds a display container. Show PlaylistThe playlist shows the currently selected media files at runtime and design time. But in the latter case without scrollbars.
Default value: Disabled Possible values: •Disabled: Removes the playlist table. •Enabled: Add a new playlist table. Show Backward / Forward ButtonsIf the target device has no encoder to set the media position by using the position bar, this property can be enabled to add a backward and a forward button to the multimedia player. With these buttons the media position can be increased or decreased
Default value: Disabled Possible values: •Disabled: Removes the backward / forward buttons from the multimedia player. •Enabled: Adds the backward / forward buttons to the multimedia player. Show Volume Bar ButtonsIf the target device has no encoder to set the volume by using the volume bar, this property can be enabled to add a volume increase and decrease button to the multimedia player. With these buttons the volume value can be increased or decreased
Default value: Disabled Possible values: •Disabled: Removes the volume increase / decrease buttons). •Enabled: Add's the volume increase / decrease buttons. Full Path In TitleThis property shows the full path of the played media file in the title string field at runtime instead of only the file name.
Default value: Disabled Possible values: •Disabled: The media title stringfield shows only the filename •Enabled: The media title stringfield shows the full path of the played media file. Playlist Media FilesBy clicking on this property, a media file chooser dialog will be displayed. Here the user can modify his playlist. This dialog supports the following operations: “Add” (1), “Remove” (2), “Up” (3) (playlist position), “Down” (4) (playlist position).
Default value: empty Possible values: Multiple media files in the supported formats (mp3, mp4, mka, mkv, mp4, oga, ogg, ogv, wav, wma, wmv). See the FAQ section below about codec information
Playlist WidthThis value adjusts the width of the playlist if it is shown. The state of this property is depending on the value of the “Show Playlist” property.
Default value: Disabled Possible values: 1 ... width of the multimedia player object - 2 x (default component gap = 2 + border width) -1 |
The ID's of all the control objects are stored as properties in the media player object. If an object is not needed , it can be deleted. The id of deleted control objects will be set to "-1.” Of course it is also possible to add / register a control object again.
Restrictions for the registration of new control objects:
- Only objects which are included in the multimedia player component can be registered.
- The object which is to be registered must contain all required events, because the default events/actions will be registered again. (e.g. it is also possible to register an arched bargraph object as volume bar instead the default linear bargraph object, because both objects have the "OnValueChange" event)
Hint: If the assignment of the new control object fails, the last valid id will retain
The group “Multimedia Player Controls” includes the following properties: |
The following events can be configured for the multimedia player object: •OnPress •OnRelease See here for the descriptions of all event and possible actions that can be assigned. |
What video and audio codecs are supported?VideoThe following video codecs have been verified on the device: •H264 - MPEG-4 AVC (part 10) (avc1) •MPEG-1/2 Video (mpgv) •Motion JPEG Video (MJPG) •Google/On2's VP8 Video (VP80) The following video codecs are currently NOT SUPPORTED on the device: •Theora Video •MPEG-4 Video (DX50) => DIVX version 5 •Any Windows media format in an AFS container (VC1, WMV) AudioThe following audio codecs have been verified on the device: •MPEG Audio layer 1/2/3 (mpga) •Vorbis Audio (vorb) •Raw wave files in different format (tested: PCM S16 LE (araw), PCM U8 (araw)) Why should VLC be installed?For using the multimedia player object it is NOT neccessary that VLC is installed on your PC but it can help in the following topics: •Check what codecs are used by specific media file •Convert (transcode) a media file to a supported codec VLC can be downloaded here. It is open source software and can be installed without charge (please consider a donation :) ). What is the suggested video and audio codec and how to convert my video?We suggest to use .mp4 files with "H264 - MPEG-4 AVC (part 10) (avc1)" as video codec and "MPEG AAC Audio (mp4a)" as audio codec. To convert to a supported codec, VLC (see above) can be used. Here is a short manual. What is the difference between the multimedia playback on Windows simulation and on the deviceThe frontend for playing back media files with the MultimediaPlayer object is the same on both platforms. However, the backend is completely different. On the Windows PC the simulation uses the capabilities of the operating system and the installed software codecs. On the device the hardware decoding functions of the CPU are directly used to minimize CPU load. Because of this difference, the playback can be different on both platforms. One of the biggest differences can be that a media file that can be played back in the simulation on the Windows PC cannot be played back on the device. This can happen if a codec is installed on the PC but is not supported by the CPU on the device. Other differences that may appear are different timings when executing a multimedia action or (e.g. when going to the next file in the playlist the total time of the next file might appear faster on one platform than on the other). We strongly recommend that testing is not only done with the Windows simulation but also directly on the device! Why is my media file not playing in the Windows simulation?There might be a codec missing. The K-Lite Codec Pack supports all the codecs supported on the device (and many more). After installing this codec pack, restart the simulation and try again. Download it here (the basic version should be enough). Do I need to be concerned about performance when playing video or audio?Yes and no. When using one of the supported codecs above, the built in hardware acceleration is used on the device to minimize CPU load (while playback the CPU load increses between 3% and 7% on a single core CPU). BUT there are some things to keep in mind: When running on a single core CPU it is more likely that playback of multimedia has an influence on the system. Especially tight CAN timings may be a problem (e.g. sending out a CAN message every 10ms might not be completely precise anymore). We strongly recommend that the project is tested on the device while playing back media with a special look at CAN (send and receive) and script timings. When running on a device with a dual or quad core CPU it is less likely that media playback has a negative influence on the overall performance. What happens when the page is changed while playback?It depends on what kind of media is played back: If a video is played back when exiting the page with the multimedia player, the playback will be stopped automatically. If only audio (music) is played back when exiting the page with the multimedia player, the playback will continue. If the audio playback shall be stopped when the page is switched, you have to stop the media player manually (e.g. via a multimediaCommand JavaScript call onPageExit). Why is the volume so low?Please have a look at the volume FAQ section. How can I control playback in JavaScript?Use the multimediaCommand function in JavaScript to control the multimedia player and it's playlist. How can I switch the video to fullscreen and how to exit fullscreen mode?Use the multimediaCommand function in JavaScript with the command string "toggle fullscreen" to enable or disable fullscreen video. Fullscreen mode is automatically disabled again as soon as the user touches the screen or presses the escape key. How can the display operator play his own media files?It is possible to add media files that are stored on an USB device to the playlist of the MultimediPlayer. To do this JavaScript needs to be used. Here is an example script that adds all files from the folder "music" on an usb stick to the playlist: //check if USB stick is inserted: var usbInserted = getVariableValue("@USBMemStatus"); if (usbInserted != 0) { //USB stick present, get the mount path var usbPath = getVariableValue("@USBMountPath"); //add "music" folder to the usb path usbPath = usbPath + "/music"; //remove all files from playlist multimediaCommand(34, "clear playlist"); //now add all files from the music directory to the playlist multimediaCommand(34, "add directory to playlist", usbPath); } else { //no usb stick present, show alarm 1 that shows an eror message setVariableValue("@AlarmShow", 0x8001); } Why can't I change the position in an MP3 file?Changing position (seeking) for MP3 encoded audio files is currently not supported by the backend. If seeking is importand, the MP3 files can be converted to e.g. MPEG AAC or Vorbis audio files. |