mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-10-11 13:41:57 +00:00
* Added: Reset Player is back. It isn't quite as robust as it was before, but it should still prove helpful when faced with certain playback issues. * Added: Clicking the `Stream Uptime` metadata now opens a small pop-up letting the user copy a link to the archived video of the current broadcast, at the current time. Please be aware that archives are not updated in real time and the link will not work for several minutes. * Changed: The `Playback Statistics` metadata now renders as a button to show feedback that you can, in fact, click on it. Doing so toggles the visibility of the player's statistics window. * Fixed: Issue importing a single profile without an update URL causing no data to be imported. (Closes #645) * Fixed: Styles for metadata buttons without borders. * Fixed: Positioning of the PiP and Reset Player buttons. * Fixed: The `Playback Statistics` metadata displaying numbers a bit too precisely for easy reading.
53 lines
No EOL
1.4 KiB
JavaScript
53 lines
No EOL
1.4 KiB
JavaScript
'use strict';
|
|
|
|
export function getBuster(resolution = 5) {
|
|
const now = Math.floor(Date.now() / 1000);
|
|
return now - (now % resolution);
|
|
}
|
|
|
|
export function duration_to_string(elapsed, separate_days, days_only, no_hours, no_seconds) {
|
|
const seconds = elapsed % 60;
|
|
let minutes = Math.floor(elapsed / 60),
|
|
hours = Math.floor(minutes / 60),
|
|
days = '';
|
|
|
|
minutes = minutes % 60;
|
|
|
|
if ( separate_days ) {
|
|
days = Math.floor(hours / 24);
|
|
hours = hours % 24;
|
|
if ( days_only && days > 0 )
|
|
return `${days} days`;
|
|
|
|
days = days > 0 ? `${days} days, ` : '';
|
|
}
|
|
|
|
const show_hours = (!no_hours || days || hours);
|
|
|
|
return `${days}${
|
|
show_hours ? `${days && hours < 10 ? '0' : ''}${hours}:` : ''
|
|
}${show_hours && minutes < 10 ? '0' : ''}${minutes}${
|
|
no_seconds ? '' : `:${seconds < 10 ? '0' : ''}${seconds}`}`;
|
|
}
|
|
|
|
|
|
export function print_duration(seconds) {
|
|
let minutes = Math.floor(seconds / 60);
|
|
const hours = Math.floor(minutes / 60);
|
|
|
|
minutes %= 60;
|
|
seconds %= 60;
|
|
|
|
return `${hours > 0 ? `${hours}:${minutes < 10 ? '0' : ''}` : ''}${minutes}:${seconds < 10 ? '0' : ''}${seconds}`;
|
|
}
|
|
|
|
|
|
export function durationForURL(elapsed) {
|
|
const seconds = elapsed % 60;
|
|
let minutes = Math.floor(elapsed / 60);
|
|
const hours = Math.floor(minutes / 60);
|
|
|
|
minutes = minutes % 60;
|
|
|
|
return `${hours > 0 ? `${hours}h` : ''}${minutes > 0 ? `${minutes}m` : ''}${seconds > 0 ? `${seconds}s` : ''}`;
|
|
} |