Hi Håvard,
I have no proper solution for OH2 but an idea how to get the information from Kodi. I tested some commands with the JSON-RPC API and gathered the following details:
This curl request gets duration
or runtime
properties. duration
for audio files/streams and runtime
for video files/streams. Problem is that the response doesn’t return a default value for a property is it is not present. It returns nothing instead which makes the parsing a little bit more complex.
curl -D- -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","method":"Player.GetItem","params":{"properties":["duration","runtime","showtitle"],"playerid":1},"id":"1"}' http://<kodi ip address>:8080/jsonrpc
Response:
{"id":"1","jsonrpc":"2.0","result":{"item":{"id":21,"label":"A World Without God","runtime":2837,"showtitle":"The Frankenstein Chronicles","type":"episode"}}}
I found another solution which returns maybe more useful information.
curl -D- -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","method":"Player.GetProperties","params":{"properties":["percentage","time","totaltime"],"playerid":1},"id":"1"}' http://<kodi ip address>:8080/jsonrpc
Response:
{"id":"1","jsonrpc":"2.0","result":{"percentage":5.0042195320129394531,"time":{"hours":0,"milliseconds":18,"minutes":2,"seconds":22},"totaltime":{"hours":0,"milliseconds":965,"minutes":47,"seconds":17}}}
Anything useful for your approach?