How do you do simple math with two values?

Hello everyone! I am trying to create a custom video play bar for an iPad app (so I can’t use a linear gauge). To do this, I want to subtract the Current Time of the video from the Total Time of the video. Is there a way to do this? Thanks!

Hi @amiller,

“Simple math” can be done using the Simple Counter but subtracting “time values” are not that simple since these values are just numbers.
To compute the remaining time of a video, I’d suggest to bind a text to the Current Time property of the video and use a Custom script converter to subtract this value from the total time of the video.


Hey @amiller,
For the play bar, you could also try to create your own version of a linear gauge with the scroll collection.
Just brainstorming here, but I’d start by using @Seb 's advice above, and then convert those two values into a percentage. (If that seems difficult to do with two time values, maybe try and convert the video times to seconds)

Put a simple rectangle in a scroll collection, overflowing past the x boundaries, and bind the x % of the percentage of the scroll collection to the % complete from your conversion above. It should tick along with your video. But you won’t be able to actively scroll this play bar to jump to a time in the video. You may need to get a little creative to accomplish that. Good luck.

Thanks @Seb and @AlexB. I’m a little confused about the custom scripts. If the Current Time is the Input, how do enter the Total Time? It seem like there is only one Input for custom script. No?

That’s correct @amiller, at the moment all the Value converters can only have 1 dynamic input. You’ll have to enter the total time manually in the script.

Yup, I see that my idea would require two inputs, so that’s not going to work. This is an example of how a seemingly simple thing can get complicated real fast. My next rough train of thought was using excel to do some calculations, so for each video, calculate how many pixels/second it would require for the scroll collection to get from start to finish. Then use a counter or something to incrementally add that pixel amount…somehow as the video plays, and bind that count to the scroll collection. This is an undeveloped thought, so it probably won’t work. But hey, sometimes brainstorming nonsense can generate further ideas, haha. Either way, the solution for this doesn’t look very easy.