Dividing Player.Duration time by 2 - Scripting: HOW-TO ?
#1
Hi,
I would like to achieve a simple things that apparently is extremely complicated. I am starting from a certain skin (in my case, it's Arctic Zephyr Reloaded, but this is not important) and I would like to display current time and the time by which 50% of the film will be reached. So, for instance, if it's 20:00 and the film is 2h long, I would like to display 21:00 on the screen.
This would be easy if I could take Player.Duration and divide it by 2 and then sum it up to the current time, but since I cannot do any math on an XML, I presumibly need to use a python script.
Unfortunately, it's almost impossible to find a tutorial on how I should build such script, how I should pass the variables, the interaction between the skin and the script and how to update the variable.
I could display the value every time I show the OSD Bar, or with a remote command keypress, or before the film starts (when I browse them), but can somebody tell me where to start? The python program as such is trivial and it would take me 2 minutes to write it, but how to wrap it into a kodi script, how to launch it, how the script should report the value back (returning the value or writing a string or writing a label?), this is pretty obscure to me.
I have searched a lot in these forums, I have seen someone helping someone else on very specific topics, but I haven't found any practical examples on how, you know, to create a simple script that writes "Hello world" or counts from 1 to 10 every second. And without any examples, it's complex.

Any help would be appreciated, at least to know the ABC and have a basic working structure. From there on, I can play with it.
Thanks!
Luca
Reply
#2
the addon upnext has something similar to what you want, it uses a service to monitor the current playback time then displays a dialog if it is x time from the end
take a look under the hood and it might include the code you need to model from - https://kodi.wiki/view/Add-on:Up_Next

a further thought, if there is a background service monitoring playback time as above then that service may be able to set (and keep updated) a window variable that the skin can read on the osd
Reply
#3
Thanks! I'll take a look.
Reply
#4
Alternatively you could look at script.embuary.helper which has a calculate function that allows you to do simple arithmetic and then returned the answer to a window property.

Are you liking to write your own script or use something already made that will do the job?
Reply
#5
If I can reuse something, then it would be great because I would just need to add this info to an existing skin.
I will look into it, this is a great suggestion!
thanks!
Reply

Logout Mark Read Team Forum Stats Members Help
Dividing Player.Duration time by 2 - Scripting: HOW-TO ?0