A Node-RED node for playing video in dashboard D2
APACHE-2.0 License
A Node-RED node for playing video in Node-RED VueJs dashboard D2.
This ui node is a successor of the node-red-ui-mp4frag, which Kevin Godell had developed for the original AngularJs Node-RED dashboard. Some code snippets for this new node have been copied shameless from Kevin's node 😋. So lots of credits go to Kevin...
CAUTION: Currently this node is EXPERIMENTAL. It is not published on NPM yet, so it need to be installed directly from this Github repo.
Run the following npm command in your Node-RED user directory (typically ~/.node-red):
npm install bartbutenaers/node-red-dashboard-2-ui-video
This node allows to play:
See the wiki for a series of tutorials about this node.
The following example flow demonstrates how to play mp4 and hls, and how to control the widget properties dynamically via input messages:
And another example flow demonstrates how to control the video via dashboard buttons:
CSS class name(s) that should be applied to this widget, in order to style the video element.
This property can be overwritten dynamically via msg.ui_update.class
: see example in wiki.
Link to a video resource (e.g. an mp4 or m3u8 file) which needs to be played.
This property can be overwritten dynamically via msg.ui_update.url
.
When active, the video will automatically start playing when an url has been specified.
This property can be overwritten dynamically via msg.ui_update.autoplay
(with possible values 'on' and 'off'): see example flow.
Note that e.g. the Chrome browser does not autoplay when the sound is on, because that can be very annoying for users.
When active, the controls will be displayed at the bottom of the video:
This property can be overwritten dynamically via msg.ui_update.controls
(with possible values 'show' and 'hide'): see example flow.
When active, the video will not be muted while playing.
This property can be overwritten dynamically via msg.ui_update.sound
(with possible values 'on' and 'off'): see example flow.
When this option is active, the video data won't be loaded when the video is not visible. For example when we switch to another dashboard tabsheet.
This property can be overwritten dynamically via msg.ui_update.unloadHiddenVideo
(with possible values 'on' and 'off'): see example flow.
This is explained further in this wiki page.
Specify the percentage of the video that needs to be visible (in the browser viewport), otherwise the video player will stop loading data:
This property can be overwritten dynamically via msg.ui_update.intersectionThreshold
(with possible values numbers between 0 and 100 percent): see example flow.
Because when the video becomes (partly) hidden by scrolling, it is in most use cases useless to keep streaming video data.
Specify which Hls library should be used to play m3u8 playlists:
This property can be overwritten dynamically via msg.ui_update.hlsLibrary
(with possible values 'native' and 'hlsjs'): see example flow.
Specify how the ui node should log his information for troubleshooting:
This property can be overwritten dynamically via msg.ui_update.logType
(with possible values 'none', 'console' and 'msg'): see example flow.
Image that will be shown inside the video player when the player has been initialized. If no poster has been specified, the first frame of the video will be displayed. See the wiki for more information.
This property can be overwritten dynamically via msg.ui_update.readyPoster
: see example flow.
See this wiki page explains how to create (ready and error) posters at runtime.
Image that will be shown inside the video player after a fatal error. If no poster has been specified, the first frame of the video will be displayed. See the wiki for more information.
This property can be overwritten dynamically via msg.ui_update.errorPoster
: see example flow.
Specify how the video will be displayed within the available area. Because the size of the video will not exactly match the available space.
This property can be overwritten dynamically via msg.ui_update.resizing
(with possible values 'none', 'fit_longest', 'fit_shortest' and 'fit_both'): see example flow.
See this wiki page for more information.
When the Hls.js library is being used, a lot of parameters can be configured. The following are the default parameters provided by this node:
true
, to handle live streams with an infinite duration. Meaning the player won’t stop playing after a certain time.5
to keep the last 5 seconds of the live stream in the back buffer, allowing for quick rewinds.10
to buffer up to 10 seconds of video content ahead of the current playback position.1000
to have a timeout of 1 second (or 1000 milliseconds) for loading the manifest file.10
which is the maximum number of retry attempts for loading the manifest file, if the initial attempt fails500
to have a delay of 0.5 seconds (or 500 milliseconds) between retry attempts for loading the manifest file.