Wrong playback time
RobertMe opened this issue · comments
Seems like (sometimes?) the runtime/duration values (for videos?) are off. When watching a video Kodi shows correctly something like 42:30, but Kodimode shows 1:00:00.
But worse than showing the wrong runtime, seeking (on the now playing page, using the progress bar) sends the values in percentages. So when you "search" (press & hold) in the progress bar you'll select a time, say 30:00, but as the percentage values (50% in this case) gets send, Kodi actually seeks to 21:15 (based on the actual runtime). Which is just totally wrong and unexpected
So we'll need to fix two things:
- try to read the correct runtime/duration from Kodi
- seek based on time, instead of percentages, based on the time we actually show the user
Both depend on what Kodi actually supports, but it seems weird to only send "wrong" runtime values on the API, so we should at least be able to fix 1., which would "hide" the issue of 2..
@mzanetti what do you know about 1? As currently both a runtime
and duration
get queried over the API, but only one is used (as duration
), for which runtime
is preferred (code first checks for the presence of runtime
, and only uses duration
when there isn't a runtime
).
After a very short bit of investigation it seems like Kodi doesn't know the proper timings of the item yet during first playback (I've also seen playback times of 00:00). If you stop and restart they are correct. So my guess is it has something to do with how Kodi reads these. Player.GetItem
probably returns the details of the library item itself initially, which most likely comes from a scraper. While the player shows the actual playback time of the file/stream. So we might want to look into reading the time from the player (Player.GetProperties
) instead of the item.
Fix implemented by using the totaltime
property of Player
. But found some other things which need to be cleaned up, as some methods of our Player
class aren't used anymore and some calls are duplicate (handling Player.OnPlay
does refresh()
which fetches a lot of properties and calls getCurrentItemDetails
but some of these properties + getCurrentItemDetails
are also getting called by the Player.OnPlay
notification handling itself, for example).
And I also want to move the percentage to time calculation from QML (which is duplicated in all apps) to C++, and reuse it for fixing 2.