Go to previous track on double click

This commit is contained in:
ferferga 2020-06-18 09:30:31 +02:00
parent 1a6e0973f3
commit 989c99521f
2 changed files with 24 additions and 8 deletions

View File

@ -157,12 +157,15 @@ define(['require', 'datetime', 'itemHelper', 'events', 'browser', 'imageLoader',
}
});
elem.querySelector('.previousTrackButton').addEventListener('click', function () {
elem.querySelector('.previousTrackButton').addEventListener('click', function (e) {
if (currentPlayer) {
if (currentPlayer.id === 'htmlaudioplayer' && (currentPlayer._currentTime <= 5 || !playbackManager.previousTrack(currentPlayer))) {
// Cancel this event if doubleclick is fired
if (e.originalEvent.detail > 1) {
return;
}
playbackManager.seekPercent(0, currentPlayer);
// This is done automatically by playbackManager, however, setting this here
// gives instant visual feedback
// This is done automatically by playbackManager, however, setting this here gives instant visual feedback
positionSlider.value = 0;
} else {
playbackManager.previousTrack(currentPlayer);
@ -170,6 +173,12 @@ define(['require', 'datetime', 'itemHelper', 'events', 'browser', 'imageLoader',
}
});
elem.querySelector('.previousTrackButton').addEventListener('dblclick', function () {
if (currentPlayer) {
playbackManager.previousTrack(currentPlayer);
}
});
elem.querySelector('.btnShuffle').addEventListener('click', function () {
if (currentPlayer) {
if (playbackManager.getPlaylistShuffleMode(currentPlayer) === 'Sorted') {

View File

@ -2,7 +2,6 @@ define(['browser', 'datetime', 'backdrop', 'libraryBrowser', 'listView', 'imageL
'use strict';
var showMuteButton = true;
var showVolumeSlider = true;
var shuffleButton;
function showAudioMenu(context, player, button, item) {
var currentIndex = playbackManager.getAudioStreamIndex(player);
@ -704,19 +703,27 @@ define(['browser', 'datetime', 'backdrop', 'libraryBrowser', 'listView', 'imageL
}
});
context.querySelector('.btnPreviousTrack').addEventListener('click', function () {
console.log(currentPlayer);
context.querySelector('.btnPreviousTrack').addEventListener('click', function (e) {
if (currentPlayer) {
if (currentPlayer.id === 'htmlaudioplayer' && (currentPlayer._currentTime <= 5 || !playbackManager.previousTrack(currentPlayer))) {
// Cancel this event if doubleclick is fired
if (e.originalEvent.detail > 1) {
return;
}
playbackManager.seekPercent(0, currentPlayer);
// This is done automatically by playbackManager. However, setting this here
// gives instant visual feedback
// This is done automatically by playbackManager. However, setting this here gives instant visual feedback
positionSlider.value = 0;
} else {
playbackManager.previousTrack(currentPlayer);
}
}
});
context.querySelector('.btnPreviousTrack').addEventListener('dblclick', function () {
if (currentPlayer) {
playbackManager.previousTrack(currentPlayer);
}
});
positionSlider.addEventListener('change', function () {
var value = this.value;