Video files are sorted by length in wrong order
-
- Posts: 1
- Joined: 08 Oct 2021 08:36
Video files are sorted by length in wrong order
Video files are sorted by length in wrong order. For example, when sorted by length, a 2-hour video display is shorter than a 3-minute video display.
- Attachments
-
- Snipaste_2021-10-08_14-59-40.png (9.32 KiB) Viewed 263 times
Re: Video files are sorted by length in wrong order
XY is not aware of what kind of data is returned by that video length property and doesn't know how to sort it correctly
Use a custom column with a script instead. That should be sortable (at least for videos not larger than 24 hours)
Use a custom column with a script instead. That should be sortable (at least for videos not larger than 24 hours)
Code: Select all
$nsecs = property("System.Media.Duration", <cc_item>);
// To get real seconds from nanoseconds
$secs = round($nsecs * 0.0000001);
$hours = $secs / 3600;
if ($hours >= 1) {
$hours = format(regexmatches($hours, "^\d+"), "00");
$secs = $secs - $hours * 3600;
} else { $hours = "00"; }
$mins = $secs / 60;
if ($mins >= 1) {
$mins = format(regexmatches($mins, "^\d+"), "00");
$secs = $secs - $mins * 60;
} else { $mins = "00"; }
return $hours . ":" . $mins . ":" . format($secs, "00");
One of my scripts helped you out? Please donate via Paypal