Fix getting track durations not working
This fixes #78 (closed)
So, as a primer, here's how GStreamer loads configuration.
- First, GStreamer doesn't know the duration of the file as it's being initially loaded, so it sets the duration to
GST_CLOCK_TIME_NONE
- GStreamer will eventually encounter a duration frame (or similar) and update the
duration
to the correct value.
But there's a problem.
GST_CLOCK_TIME_NONE
, which has the value of 18446744073709551615
is too large for JavaScript. This is why GJS complains and logs the errors:
(com.vixalien.decibelsDevel:2): Gjs-WARNING **: 18:45:49.190: Value 18446744073709551615 cannot be safely stored in a JS Number and may be rounded
(com.vixalien.decibelsDevel:2): Gjs-WARNING **: 18:45:49.190: Value 18446744073709551615 cannot be safely stored in a JS Number and may be rounded
To fix this, everytime we detect a duration of GST_CLOCK_TIME_NONE
, we told the duration
to be 100
seconds (1:40) and that's what you got.
The reason it wasn't getting updated is because the duration
property of GtkMediaStream
only reflects the initial duration and doesn't reflect changes made afterwards (i.e. returned by the get_duration
method).
This will require a one-line change in GtkMediaStream, and I will create the MR soon where I'm in a place with a better connection (I can't currently fetch the whole gtk source on this slow network). Maybe this should only get merged after the relevant GTK MR is merged.