The latter method is the correct way to call the duration function on the video node i.e.
This will return the duration of the video the event is called on, in milliseconds.
However, the duration of the video may not be known at the moment you call the function in the script.
As a fail-safe, you can use the function within an ‘.on(“duration”)’ event handler which is emitted once the duration of the video is known.
In the script below I create a reference to my video node and declare a new variable beneath it, which I will later assign the video’s duration to.
Below that, within the event handler, I call the ‘duration()’ function on the video node and assign it’s value to the ‘duration’ variable.
I’m then able to use the ‘duration’ variable in other parts of my script, without having to call the function every time.
Also, if you’re looking to learn some scripting you may find the pages linked below helpful:
You’ll also find information on functions, the arguments they take and how to call them on the References section of our docs pages:
Hope this helps.
All the best,