mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-20 04:18:19 -07:00
Repeat track if going back when less than 5 seconds of the item has been playing
This commit is contained in:
parent
e2f61c67b9
commit
4159268949
@ -117,8 +117,13 @@ define(['require', 'datetime', 'itemHelper', 'events', 'browser', 'imageLoader',
|
|||||||
nowPlayingImageElement = elem.querySelector('.nowPlayingImage');
|
nowPlayingImageElement = elem.querySelector('.nowPlayingImage');
|
||||||
nowPlayingTextElement = elem.querySelector('.nowPlayingBarText');
|
nowPlayingTextElement = elem.querySelector('.nowPlayingBarText');
|
||||||
nowPlayingUserData = elem.querySelector('.nowPlayingBarUserDataButtons');
|
nowPlayingUserData = elem.querySelector('.nowPlayingBarUserDataButtons');
|
||||||
|
positionSlider = elem.querySelector('.nowPlayingBarPositionSlider');
|
||||||
muteButton = elem.querySelector('.muteButton');
|
muteButton = elem.querySelector('.muteButton');
|
||||||
|
playPauseButtons = elem.querySelectorAll('.playPauseButton');
|
||||||
|
toggleRepeatButton = elem.querySelector('.toggleRepeatButton');
|
||||||
|
volumeSlider = elem.querySelector('.nowPlayingBarVolumeSlider');
|
||||||
|
volumeSliderContainer = elem.querySelector('.nowPlayingBarVolumeSliderContainer');
|
||||||
|
|
||||||
muteButton.addEventListener('click', function () {
|
muteButton.addEventListener('click', function () {
|
||||||
|
|
||||||
if (currentPlayer) {
|
if (currentPlayer) {
|
||||||
@ -134,7 +139,6 @@ define(['require', 'datetime', 'itemHelper', 'events', 'browser', 'imageLoader',
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
playPauseButtons = elem.querySelectorAll('.playPauseButton');
|
|
||||||
playPauseButtons.forEach((button) => {
|
playPauseButtons.forEach((button) => {
|
||||||
button.addEventListener('click', onPlayPauseClick);
|
button.addEventListener('click', onPlayPauseClick);
|
||||||
});
|
});
|
||||||
@ -147,10 +151,16 @@ define(['require', 'datetime', 'itemHelper', 'events', 'browser', 'imageLoader',
|
|||||||
});
|
});
|
||||||
|
|
||||||
elem.querySelector('.previousTrackButton').addEventListener('click', function () {
|
elem.querySelector('.previousTrackButton').addEventListener('click', function () {
|
||||||
|
|
||||||
if (currentPlayer) {
|
if (currentPlayer) {
|
||||||
|
if (currentPlayer.id === 'htmlaudioplayer' && (currentPlayer._currentTime <= 5 || !playbackManager.previousTrack(currentPlayer))) {
|
||||||
|
playbackManager.seekPercent(0, currentPlayer);
|
||||||
|
// This is done automatically by playbackManager, however, setting this here
|
||||||
|
// gives instant visual feedback
|
||||||
|
positionSlider.value = 0;
|
||||||
|
} else {
|
||||||
playbackManager.previousTrack(currentPlayer);
|
playbackManager.previousTrack(currentPlayer);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
toggleRepeatButton = elem.querySelector('.toggleRepeatButton');
|
toggleRepeatButton = elem.querySelector('.toggleRepeatButton');
|
||||||
@ -174,9 +184,6 @@ define(['require', 'datetime', 'itemHelper', 'events', 'browser', 'imageLoader',
|
|||||||
|
|
||||||
toggleRepeatButtonIcon = toggleRepeatButton.querySelector('.material-icons');
|
toggleRepeatButtonIcon = toggleRepeatButton.querySelector('.material-icons');
|
||||||
|
|
||||||
volumeSlider = elem.querySelector('.nowPlayingBarVolumeSlider');
|
|
||||||
volumeSliderContainer = elem.querySelector('.nowPlayingBarVolumeSliderContainer');
|
|
||||||
|
|
||||||
if (appHost.supports('physicalvolumecontrol')) {
|
if (appHost.supports('physicalvolumecontrol')) {
|
||||||
volumeSliderContainer.classList.add('hide');
|
volumeSliderContainer.classList.add('hide');
|
||||||
} else {
|
} else {
|
||||||
@ -193,7 +200,6 @@ define(['require', 'datetime', 'itemHelper', 'events', 'browser', 'imageLoader',
|
|||||||
volumeSlider.addEventListener('mousemove', setVolume);
|
volumeSlider.addEventListener('mousemove', setVolume);
|
||||||
volumeSlider.addEventListener('touchmove', setVolume);
|
volumeSlider.addEventListener('touchmove', setVolume);
|
||||||
|
|
||||||
positionSlider = elem.querySelector('.nowPlayingBarPositionSlider');
|
|
||||||
positionSlider.addEventListener('change', function () {
|
positionSlider.addEventListener('change', function () {
|
||||||
|
|
||||||
if (currentPlayer) {
|
if (currentPlayer) {
|
||||||
|
@ -606,6 +606,7 @@ define(['browser', 'datetime', 'backdrop', 'libraryBrowser', 'listView', 'imageL
|
|||||||
|
|
||||||
function bindEvents(context) {
|
function bindEvents(context) {
|
||||||
var btnCommand = context.querySelectorAll('.btnCommand');
|
var btnCommand = context.querySelectorAll('.btnCommand');
|
||||||
|
var positionSlider = context.querySelector('.nowPlayingPositionSlider');
|
||||||
|
|
||||||
for (var i = 0, length = btnCommand.length; i < length; i++) {
|
for (var i = 0, length = btnCommand.length; i < length; i++) {
|
||||||
btnCommand[i].addEventListener('click', onBtnCommandClick);
|
btnCommand[i].addEventListener('click', onBtnCommandClick);
|
||||||
@ -654,11 +655,19 @@ define(['browser', 'datetime', 'backdrop', 'libraryBrowser', 'listView', 'imageL
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
context.querySelector('.btnPreviousTrack').addEventListener('click', function () {
|
context.querySelector('.btnPreviousTrack').addEventListener('click', function () {
|
||||||
|
console.log(currentPlayer);
|
||||||
if (currentPlayer) {
|
if (currentPlayer) {
|
||||||
|
if (currentPlayer.id === 'htmlaudioplayer' && (currentPlayer._currentTime <= 5 || !playbackManager.previousTrack(currentPlayer))) {
|
||||||
|
playbackManager.seekPercent(0, currentPlayer);
|
||||||
|
// This is done automatically by playbackManager. However, setting this here
|
||||||
|
// gives instant visual feedback
|
||||||
|
positionSlider.value = 0;
|
||||||
|
} else {
|
||||||
playbackManager.previousTrack(currentPlayer);
|
playbackManager.previousTrack(currentPlayer);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
context.querySelector('.nowPlayingPositionSlider').addEventListener('change', function () {
|
positionSlider.addEventListener('change', function () {
|
||||||
var value = this.value;
|
var value = this.value;
|
||||||
|
|
||||||
if (currentPlayer) {
|
if (currentPlayer) {
|
||||||
@ -667,7 +676,7 @@ define(['browser', 'datetime', 'backdrop', 'libraryBrowser', 'listView', 'imageL
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
context.querySelector('.nowPlayingPositionSlider').getBubbleText = function (value) {
|
positionSlider.getBubbleText = function (value) {
|
||||||
var state = lastPlayerState;
|
var state = lastPlayerState;
|
||||||
|
|
||||||
if (!state || !state.NowPlayingItem || !currentRuntimeTicks) {
|
if (!state || !state.NowPlayingItem || !currentRuntimeTicks) {
|
||||||
|
Loading…
Reference in New Issue
Block a user