Speakr is a personal, self-hosted web application designed for transcribing audio recordings
Python
Improve mobile audio player and add localization for player tooltips
Murtaza Nasirccc1bd7718ed
diff --git a/static/js/modules/composables/ui.js b/static/js/modules/composables/ui.jsindex 32ebebee..4feb8895 100644--- a/static/js/modules/composables/ui.js+++ b/static/js/modules/composables/ui.js@@ -885,13 +885,20 @@ export function useUI(state, utils, processedTranscription) {const isDraggingProgress = ref(false);const dragPreviewPercent = ref(0);- // Handle progress bar drag - only seeks on release for better performance+ // Handle progress bar drag - supports both mouse and touch, only seeks on releaseconst startProgressDrag = (event) => {const bar = event.currentTarget.querySelector('.h-2') || event.currentTarget;const rect = bar.getBoundingClientRect();+ const isTouch = event.type === 'touchstart';const getPercent = (evt) => {- return Math.max(0, Math.min(100, ((evt.clientX - rect.left) / rect.width) * 100));+ const clientX = isTouch ? evt.touches[0].clientX : evt.clientX;+ return Math.max(0, Math.min(100, ((clientX - rect.left) / rect.width) * 100));+ };++ const getPercentFromEnd = (evt) => {+ const clientX = isTouch ? evt.changedTouches[0].clientX : evt.clientX;+ return Math.max(0, Math.min(100, ((clientX - rect.left) / rect.width) * 100));};// Start dragging - show preview@@ -900,19 +907,20 @@ export function useUI(state, utils, processedTranscription) {const onMove = (evt) => {evt.preventDefault();- dragPreviewPercent.value = getPercent(evt);+ const clientX = isTouch ? evt.touches[0].clientX : evt.clientX;+ dragPreviewPercent.value = Math.max(0, Math.min(100, ((clientX - rect.left) / rect.width) * 100));};const onUp = (evt) => {- document.removeEventListener('mousemove', onMove);- document.removeEventListener('mouseup', onUp);+ document.removeEventListener(isTouch ? 'touchmove' : 'mousemove', onMove);+ document.removeEventListener(isTouch ? 'touchend' : 'mouseup', onUp);// Seek to final position on releaseseekAudioByPercent(dragPreviewPercent.value);isDraggingProgress.value = false;};- document.addEventListener('mousemove', onMove);- document.addEventListener('mouseup', onUp);+ document.addEventListener(isTouch ? 'touchmove' : 'mousemove', onMove, { passive: false });+ document.addEventListener(isTouch ? 'touchend' : 'mouseup', onUp);};const handleAudioPlayPause = (event) => {diff --git a/static/locales/de.json b/static/locales/de.jsonindex 5bc629cb..e0ba8f60 100644--- a/static/locales/de.json+++ b/static/locales/de.json@@ -1105,6 +1105,10 @@"followPlayerDisabled": "Automatisches Scrollen aktivieren - Transkript folgt der Audiowiedergabe","followPlayerEnabled": "Automatisches Scrollen deaktivieren - Transkript bleibt an Ort und Stelle","minimize": "Minimieren",- "expand": "Erweitern"+ "expand": "Erweitern",+ "play": "Abspielen",+ "pause": "Pause",+ "mute": "Stumm",+ "unmute": "Ton an"}}\ No newline at end of filediff --git a/static/locales/en.json b/static/locales/en.jsonindex aa78c920..e04f964f 100644--- a/static/locales/en.json+++ b/static/locales/en.json@@ -1100,6 +1100,10 @@"followPlayerDisabled": "Enable auto-scroll - transcript follows audio playback","followPlayerEnabled": "Disable auto-scroll - transcript stays in place","minimize": "Minimize",- "expand": "Expand"+ "expand": "Expand",+ "play": "Play",+ "pause": "Pause",+ "mute": "Mute",+ "unmute": "Unmute"}}\ No newline at end of filediff --git a/static/locales/es.json b/static/locales/es.jsonindex fe722610..a7980c69 100644--- a/static/locales/es.json+++ b/static/locales/es.json@@ -1074,6 +1074,10 @@"followPlayerDisabled": "Activar desplazamiento automático - la transcripción sigue la reproducción de audio","followPlayerEnabled": "Desactivar desplazamiento automático - la transcripción permanece en su lugar","minimize": "Minimizar",- "expand": "Expandir"+ "expand": "Expandir",+ "play": "Reproducir",+ "pause": "Pausa",+ "mute": "Silenciar",+ "unmute": "Activar sonido"}}\ No newline at end of filediff --git a/static/locales/fr.json b/static/locales/fr.jsonindex a293611a..9a3d5f7a 100644--- a/static/locales/fr.json+++ b/static/locales/fr.json@@ -1074,6 +1074,10 @@"followPlayerDisabled": "Activer le défilement automatique - la transcription suit la lecture audio","followPlayerEnabled": "Désactiver le défilement automatique - la transcription reste en place","minimize": "Réduire",- "expand": "Développer"+ "expand": "Développer",+ "play": "Lecture",+ "pause": "Pause",+ "mute": "Muet",+ "unmute": "Activer le son"}}\ No newline at end of filediff --git a/static/locales/ru.json b/static/locales/ru.jsonindex f41b0ed0..bd4f3f27 100644--- a/static/locales/ru.json+++ b/static/locales/ru.json@@ -1099,6 +1099,10 @@"followPlayerDisabled": "Включить автопрокрутку - транскрипт следует за воспроизведением аудио","followPlayerEnabled": "Отключить автопрокрутку - транскрипт остаётся на месте","minimize": "Свернуть",- "expand": "Развернуть"+ "expand": "Развернуть",+ "play": "Воспроизвести",+ "pause": "Пауза",+ "mute": "Без звука",+ "unmute": "Включить звук"}}diff --git a/static/locales/zh.json b/static/locales/zh.jsonindex d82f99e7..08f8a2c1 100644--- a/static/locales/zh.json+++ b/static/locales/zh.json@@ -1258,6 +1258,10 @@"followPlayerDisabled": "启用自动滚动 - 文字记录跟随音频播放","followPlayerEnabled": "禁用自动滚动 - 文字记录保持位置","minimize": "最小化",- "expand": "展开"+ "expand": "展开",+ "play": "播放",+ "pause": "暂停",+ "mute": "静音",+ "unmute": "取消静音"}}\ No newline at end of filediff --git a/templates/components/detail/audio-player.html b/templates/components/detail/audio-player.htmlindex d030eaae..cddd8b8a 100644--- a/templates/components/detail/audio-player.html+++ b/templates/components/detail/audio-player.html@@ -7,7 +7,7 @@<span v-text="t('help.audioDeletedMessage')"></span></div><!-- Custom Audio Player -->- <div v-else class="flex items-center gap-3">+ <div v-else><!-- Hidden audio element --><audio ref="audioPlayerElement":src="'/audio/' + selectedRecording.id"@@ -22,42 +22,55 @@class="hidden"></audio>- <!-- Play/Pause Button -->- <button @click="toggleAudioPlayback"- class="w-10 h-10 flex items-center justify-center rounded-full bg-[var(--bg-accent)] hover:bg-[var(--bg-accent-hover)] text-white transition-all duration-200 flex-shrink-0 shadow-sm"- :title="audioIsPlaying ? 'Pause' : 'Play'">- <i :class="audioIsPlaying ? 'fas fa-pause' : 'fas fa-play'" class="text-base" :style="!audioIsPlaying ? 'margin-left: 2px' : ''"></i>- </button>-- <!-- Progress Bar & Time (stacked on mobile) -->- <div class="flex-1 flex flex-col gap-1">- <!-- Progress Bar -->- <div class="w-full h-2 bg-[var(--bg-tertiary)] rounded-full cursor-pointer group relative"- @click="(e) => { const rect = e.currentTarget.getBoundingClientRect(); seekAudioByPercent(((e.clientX - rect.left) / rect.width) * 100); }">- <div class="h-full bg-[var(--bg-accent)] rounded-full transition-all duration-100 relative"- :style="{ width: audioProgressPercent + '%' }">- <div class="absolute right-0 top-1/2 -translate-y-1/2 w-3.5 h-3.5 bg-[var(--bg-accent)] rounded-full opacity-0 group-hover:opacity-100 transition-opacity shadow-sm"></div>- </div>+ <!-- Progress Bar (draggable, touch support) -->+ <div class="w-full h-4 rounded-full cursor-pointer relative mb-2 group flex items-center"+ @mousedown="startProgressDrag"+ @touchstart.prevent="startProgressDrag">+ <!-- Track background -->+ <div class="w-full h-2 rounded-full relative" style="background: rgba(128, 128, 128, 0.4);">+ <!-- Progress fill -->+ <div class="h-full bg-[var(--bg-accent)] rounded-full pointer-events-none"+ :style="{ width: audioProgressPercent + '%' }"></div>+ <!-- Progress dot - stays within track bounds -->+ <div class="absolute top-1/2 w-4 h-4 bg-[var(--bg-accent)] rounded-full shadow-md transition-transform group-hover:scale-110 pointer-events-none -translate-y-1/2"+ :style="{ left: 'clamp(0px, calc(' + audioProgressPercent + '% - 8px), calc(100% - 16px))' }"+ style="box-shadow: 0 2px 6px rgba(0,0,0,0.3);"></div></div>- <!-- Time Display -->- <span class="text-xs text-[var(--text-muted)] font-mono">- ${ formatAudioTime(audioCurrentTime) } / ${ formatAudioTime(audioDuration) }- </span></div>- <!-- Volume Button (simplified for mobile) -->- <button @click="toggleAudioMute"- class="w-9 h-9 flex items-center justify-center rounded-lg hover:bg-[var(--bg-tertiary)] text-[var(--text-muted)] hover:text-[var(--text-primary)] transition-all flex-shrink-0"- :title="audioIsMuted ? 'Unmute' : 'Mute'">- <i :class="audioIsMuted || playerVolume === 0 ? 'fas fa-volume-mute' : 'fas fa-volume-up'" class="text-base"></i>- </button>+ <!-- Controls Row -->+ <div class="flex items-center gap-2">+ <!-- Play/Pause Button -->+ <button @click="toggleAudioPlayback"+ class="w-10 h-10 flex items-center justify-center rounded-full bg-[var(--bg-accent)] hover:bg-[var(--bg-accent-hover)] text-white transition-all duration-200 flex-shrink-0 shadow-md hover:shadow-lg active:scale-95"+ :title="audioIsPlaying ? t('tooltips.pause') : t('tooltips.play')">+ <i :class="audioIsPlaying ? 'fas fa-pause' : 'fas fa-play'" class="text-base" :style="!audioIsPlaying ? 'margin-left: 2px' : ''"></i>+ </button>++ <!-- Time Display -->+ <div class="flex items-baseline gap-1 flex-shrink-0">+ <span class="text-sm font-semibold font-mono" :class="isDraggingProgress ? 'text-[var(--text-accent)]' : 'text-[var(--text-primary)]'">${ formatAudioTime(displayCurrentTime) }</span>+ <span class="text-xs text-[var(--text-muted)]">/</span>+ <span class="text-xs text-[var(--text-muted)] font-mono">${ formatAudioTime(audioDuration) }</span>+ </div>++ <!-- Spacer -->+ <div class="flex-1"></div>- <!-- Download Button -->- <a :href="'/audio/' + selectedRecording.id + '?download=true'"- download- class="w-9 h-9 flex items-center justify-center rounded-lg hover:bg-[var(--bg-tertiary)] text-[var(--text-muted)] hover:text-[var(--text-primary)] transition-all flex-shrink-0"- :title="t('buttons.downloadAudio') || 'Download audio'">- <i class="fas fa-download text-base"></i>- </a>+ <!-- Volume Button -->+ <button @click="toggleAudioMute"+ class="w-8 h-8 flex items-center justify-center rounded-lg hover:bg-[var(--bg-primary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-all flex-shrink-0"+ :title="audioIsMuted ? t('tooltips.unmute') : t('tooltips.mute')">+ <i :class="audioIsMuted || playerVolume === 0 ? 'fas fa-volume-mute' : 'fas fa-volume-up'" class="text-sm"></i>+ </button>++ <!-- Download Button -->+ <a :href="'/audio/' + selectedRecording.id + '?download=true'"+ download+ class="w-8 h-8 flex items-center justify-center rounded-lg hover:bg-[var(--bg-primary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-all flex-shrink-0"+ :title="t('buttons.downloadAudio') || 'Download audio'">+ <i class="fas fa-download text-sm"></i>+ </a>+ </div></div></div>diff --git a/templates/components/detail/desktop-right-panel.html b/templates/components/detail/desktop-right-panel.htmlindex 2a917d9d..36046b19 100644--- a/templates/components/detail/desktop-right-panel.html+++ b/templates/components/detail/desktop-right-panel.html@@ -44,7 +44,7 @@<!-- Play/Pause Button --><button @click="toggleAudioPlayback"class="w-10 h-10 flex items-center justify-center rounded-full bg-[var(--bg-accent)] hover:bg-[var(--bg-accent-hover)] text-white transition-all duration-200 flex-shrink-0 shadow-md hover:shadow-lg hover:scale-105"- :title="audioIsPlaying ? 'Pause' : 'Play'">+ :title="audioIsPlaying ? t('tooltips.pause') : t('tooltips.play')"><i :class="audioIsPlaying ? 'fas fa-pause' : 'fas fa-play'" class="text-base" :style="!audioIsPlaying ? 'margin-left: 2px' : ''"></i></button>@@ -62,7 +62,7 @@<div class="hidden sm:flex items-center gap-1 flex-shrink-0"><button @click="toggleAudioMute"class="w-8 h-8 flex items-center justify-center rounded-lg hover:bg-[var(--bg-primary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-all"- :title="audioIsMuted ? 'Unmute' : 'Mute'">+ :title="audioIsMuted ? t('tooltips.unmute') : t('tooltips.mute')"><i :class="audioIsMuted || playerVolume === 0 ? 'fas fa-volume-mute' : playerVolume < 0.5 ? 'fas fa-volume-down' : 'fas fa-volume-up'" class="text-sm"></i></button><input type="range" min="0" max="1" step="0.05"