Hi, I am trying to figure out how to get the video duration from a video file URL. I found a plugin that can do this, but it only does this one at a time and cannot do this via a workflow (you need to put the file in the frontend and not just a URL in the backend). I came across this code, which does exactly what I need it to do, however, I am not super savvy when it comes to Javascript, but I am assuming there is some way to out this into the “run javascript” action using the ToolBox plugin, so I can put in the URL of the video file and it can return the duration, as it does with the code: (snippet here and screenshot below) - get duration - Droplr
I had a little play around with this and have a solution for you using Run JavaScript and JavaScript To Bubble. You can create HTML elements programmatically with JavaScript.
I created a container for the video element with an HTML ID. On a button click I have a Run JavaScript with:
let videoElement = document.createElement(“video”);
let containerElement = document.getElementById(“videoContainer”);
containerElement.append(videoElement);
Then I created a Custom Event that I schedule after 1 second to give the video time to load, and a JavaScript to Bubble element to return the duration. The custom workflow contains JavaScript:
let videoElement = document.getElementById(“videoElement”);
let videoDuration = videoElement.duration;
console.log(videoDuration);
bubble_fn_videoLength(videoDuration);
The JavaScript to Bubble is set to receive a number, publish the value, and trigger an event, which sets a page state so the value can be displayed.
The Ultimate Toolkit plugin has a For Each element, which would allow you to iterate through multiple URLs using an adapted version of this.