mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Added toggle to show/hide remaining video time in video player
Toggle applied to the remaining time label of the video player and added `-` as a prefix of the remaining time, both behaviours like in VLC. Toggle preference as user setting.
This commit is contained in:
parent
6e66e224a9
commit
c33dc8cd7a
2 changed files with 40 additions and 5 deletions
|
@ -787,12 +787,18 @@ import { setBackdropTransparency, TRANSPARENCY_LEVEL } from '../../../components
|
|||
nowPlayingPositionText.classList.add('hide');
|
||||
}
|
||||
|
||||
const leftTicks = runtimeTicks - positionTicks;
|
||||
if (leftTicks >= 0) {
|
||||
updateTimeText(nowPlayingDurationText, leftTicks);
|
||||
nowPlayingDurationText.classList.remove('hide');
|
||||
if (userSettings.enableVideoRemainingTime()) {
|
||||
const leftTicks = runtimeTicks - positionTicks;
|
||||
if (leftTicks >= 0) {
|
||||
updateTimeText(nowPlayingDurationText, leftTicks);
|
||||
nowPlayingDurationText.innerHTML = '-' + nowPlayingDurationText.innerHTML;
|
||||
nowPlayingDurationText.classList.remove('hide');
|
||||
} else {
|
||||
nowPlayingPositionText.classList.add('hide');
|
||||
}
|
||||
} else {
|
||||
nowPlayingPositionText.classList.add('hide');
|
||||
updateTimeText(nowPlayingDurationText, runtimeTicks);
|
||||
nowPlayingDurationText.classList.remove('hide');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -871,6 +877,19 @@ import { setBackdropTransparency, TRANSPARENCY_LEVEL } from '../../../components
|
|||
elem.innerHTML = html;
|
||||
}
|
||||
|
||||
function nowPlayingDurationTextClick() {
|
||||
if (userSettings.enableVideoRemainingTime()) {
|
||||
userSettings.enableVideoRemainingTime(false);
|
||||
} else {
|
||||
userSettings.enableVideoRemainingTime(true);
|
||||
}
|
||||
// immediately update the text, without waiting for the next tick update or if the player is paused
|
||||
const state = playbackManager.getPlayerState(currentPlayer);
|
||||
const playState = state.PlayState;
|
||||
const nowPlayingItem = state.NowPlayingItem;
|
||||
updateTimeDisplay(playState.PositionTicks, nowPlayingItem.RunTimeTicks, playState.PlaybackStartTimeTicks, playState.PlaybackRate, playState.BufferedRanges || []);
|
||||
}
|
||||
|
||||
function onSettingsButtonClick() {
|
||||
const btn = this;
|
||||
|
||||
|
@ -1330,6 +1349,8 @@ import { setBackdropTransparency, TRANSPARENCY_LEVEL } from '../../../components
|
|||
nowPlayingPositionSlider.classList.add('focusable');
|
||||
}
|
||||
|
||||
nowPlayingDurationText.addEventListener('click', nowPlayingDurationTextClick);
|
||||
|
||||
view.addEventListener('viewbeforeshow', function () {
|
||||
headerElement.classList.add('osdHeader');
|
||||
setBackdropTransparency(TRANSPARENCY_LEVEL.Full);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue