This is the code I use for my video review system.
I wrote it years ago for creating a template for the dashboard.
It still works for my the customers needs.
const video_URL = msg.video_URL;
const video_times = msg.video_times;
const video_uid = msg.video_uid;
var template = msg.template;
video_URL.forEach(function(url, index){
template += '<div><center><b>' + video_times[index] + '</b></center><video id="' + video_uid[index] + '" width="300" controls preload="none" poster="' + url + '.thumb"><source src="' + url + '"type="video/mp4">Your browser does not support HTML5 video.</video><center><button class="button button1" onclick="setPlaySpeed(0.25,' + video_uid[index] + ')" type="button"><b>1/4</b></button><button class="button button1" onclick="setPlaySpeed(0.5,' + video_uid[index] + ')" type="button"><b>1/2</b></button><button class="button button2" onclick="setPlaySpeed(1,' + video_uid[index] + ')" type="button"><b>Normal</b></button><button class="button button1" onclick="setPlaySpeed(2,' + video_uid[index] + ')" type="button"><b>2x</b></button><button class="button button1" onclick="setPlaySpeed(4,' + video_uid[index] + ')" type="button"><b>4x</b></button><button class="button button1" onclick="setPlaySpeed(8,' + video_uid[index] + ')" type="button"><b>8x</b></button><button class="button button1" onclick="setPlaySpeed(16,' + video_uid[index] + ')" type="button"><b>16x</b></button><button class="button button1" onclick="setPlaySpeed(32,' + video_uid[index] + ')" type="button"><b>32x</b></button></center></div><p></p><p></p><p></p>';
});
template += '<script>'
video_uid.forEach(function(uid){
template += 'var ' + uid + ' = document.getElementById("' + uid + '");';
});
template += 'function setPlaySpeed(speed,id) { id.playbackRate = speed; } </script> </body> </html>';
msg.template = template;
return msg;
here is the section of the flow that is relevant.
[
{
"id": "12b43459dd1bb58c",
"type": "template",
"z": "6a54a4bb6e1f85a9",
"name": "",
"field": "template",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "<!DOCTYPE html>\n<html>\n<head>\n<style>\n.button {\n background-color: #2B2B2A; /* Green */\n border: none;\n color: white;\n padding: 2px 2px;\n text-align: center;\n text-decoration: none;\n display: inline-block;\n font-size: 12px;\n margin: 0px 0px;\n cursor: pointer;\n}\n\n.button1 {width: 30px;}\n.button2 {width: 50px;}\n</style>\n</head>\n<body>\n",
"output": "str",
"x": 300,
"y": 1380,
"wires": [
[
"3af83cb30ab2bf3f"
]
]
},
{
"id": "3af83cb30ab2bf3f",
"type": "function",
"z": "6a54a4bb6e1f85a9",
"name": "",
"func": "const video_URL = msg.video_URL;\nconst video_times = msg.video_times;\nconst video_uid = msg.video_uid;\nvar template = msg.template;\nvideo_URL.forEach(function(url, index){\n template += '<div><center><b>' + video_times[index] + '</b></center><video id=\"' + video_uid[index] + '\" width=\"300\" controls preload=\"none\" poster=\"' + url + '.thumb\"><source src=\"' + url + '\"type=\"video/mp4\">Your browser does not support HTML5 video.</video><center><button class=\"button button1\" onclick=\"setPlaySpeed(0.25,' + video_uid[index] + ')\" type=\"button\"><b>1/4</b></button><button class=\"button button1\" onclick=\"setPlaySpeed(0.5,' + video_uid[index] + ')\" type=\"button\"><b>1/2</b></button><button class=\"button button2\" onclick=\"setPlaySpeed(1,' + video_uid[index] + ')\" type=\"button\"><b>Normal</b></button><button class=\"button button1\" onclick=\"setPlaySpeed(2,' + video_uid[index] + ')\" type=\"button\"><b>2x</b></button><button class=\"button button1\" onclick=\"setPlaySpeed(4,' + video_uid[index] + ')\" type=\"button\"><b>4x</b></button><button class=\"button button1\" onclick=\"setPlaySpeed(8,' + video_uid[index] + ')\" type=\"button\"><b>8x</b></button><button class=\"button button1\" onclick=\"setPlaySpeed(16,' + video_uid[index] + ')\" type=\"button\"><b>16x</b></button><button class=\"button button1\" onclick=\"setPlaySpeed(32,' + video_uid[index] + ')\" type=\"button\"><b>32x</b></button></center></div><p></p><p></p><p></p>';\n});\ntemplate += '<script>'\nvideo_uid.forEach(function(uid){\n template += 'var ' + uid + ' = document.getElementById(\"' + uid + '\");';\n});\ntemplate += 'function setPlaySpeed(speed,id) { id.playbackRate = speed; } </script> </body> </html>';\n\nmsg.template = template;\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 440,
"y": 1380,
"wires": [
[
"e02acfd322b3dc8d"
]
]
},
{
"id": "e02acfd322b3dc8d",
"type": "change",
"z": "6a54a4bb6e1f85a9",
"name": "msg.payload --> msg.template",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "template",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 650,
"y": 1380,
"wires": [
[
"21db4f64d3a8f9ba",
"ba4b5b54aea00f25"
]
]
},
{
"id": "ba4b5b54aea00f25",
"type": "debug",
"z": "6a54a4bb6e1f85a9",
"name": "",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 970,
"y": 1420,
"wires": []
},
{
"id": "21db4f64d3a8f9ba",
"type": "ui_template",
"z": "6a54a4bb6e1f85a9",
"group": "d9a84a21f5a6ac42",
"name": "",
"order": 4,
"width": 6,
"height": 8,
"format": "<div ng-bind-html=\"msg.payload\"></div>",
"storeOutMessages": true,
"fwdInMessages": true,
"resendOnRefresh": true,
"templateScope": "local",
"className": "",
"x": 980,
"y": 1380,
"wires": [
[]
]
},
{
"id": "d9a84a21f5a6ac42",
"type": "ui_group",
"name": "Default",
"tab": "1f8908e3d5c1435e",
"order": 1,
"disp": false,
"width": "6",
"collapse": false,
"className": ""
},
{
"id": "1f8908e3d5c1435e",
"type": "ui_tab",
"name": "Review",
"icon": "dashboard",
"order": 3,
"disabled": false,
"hidden": true
}
]