Speakr is a personal, self-hosted web application designed for transcribing audio recordings
Python
Add custom audio player with full theme support
Murtaza Nasirdefed16b703e
diff --git a/static/css/styles.css b/static/css/styles.cssindex b6cb6d73..503e7757 100644--- a/static/css/styles.css+++ b/static/css/styles.css@@ -2831,6 +2831,59 @@ body {color-scheme: dark;}+/* Custom volume slider styling - matches progress bar */+.volume-slider {+ -webkit-appearance: none;+ appearance: none;+ background: transparent;+ cursor: pointer;+ height: 8px;+}++.volume-slider::-webkit-slider-runnable-track {+ background: var(--bg-tertiary);+ height: 8px;+ border-radius: 4px;+}++.volume-slider::-webkit-slider-thumb {+ -webkit-appearance: none;+ appearance: none;+ width: 14px;+ height: 14px;+ border-radius: 50%;+ background: var(--bg-accent);+ margin-top: -3px;+ box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);+ cursor: pointer;+}++.volume-slider::-moz-range-track {+ background: var(--bg-tertiary);+ height: 8px;+ border-radius: 4px;+}++.volume-slider::-moz-range-thumb {+ width: 14px;+ height: 14px;+ border-radius: 50%;+ background: var(--bg-accent);+ border: none;+ box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);+ cursor: pointer;+}++.volume-slider:hover::-webkit-slider-thumb {+ transform: scale(1.15);+ box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);+}++.volume-slider:hover::-moz-range-thumb {+ transform: scale(1.15);+ box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);+}+/* Custom audio player wrapper for better control */.custom-audio-wrapper {position: relative;diff --git a/static/js/app.modular.js b/static/js/app.modular.jsindex e68b3b49..8091f525 100644--- a/static/js/app.modular.js+++ b/static/js/app.modular.js@@ -338,6 +338,11 @@ document.addEventListener('DOMContentLoaded', async () => {// --- Audio Player State ---const playerVolume = ref(1.0);+ const audioIsPlaying = ref(false);+ const audioCurrentTime = ref(0);+ const audioDuration = ref(0);+ const audioIsMuted = ref(false);+ const audioIsLoading = ref(false);const asrEditorAudio = ref(null);// --- Column Resizing State ---@@ -491,7 +496,7 @@ document.addEventListener('DOMContentLoaded', async () => {showChat, isChatMaximized, chatMessages, chatInput, isChatLoading, chatMessagesRef,// Audio Player- playerVolume, asrEditorAudio,+ playerVolume, audioIsPlaying, audioCurrentTime, audioDuration, audioIsMuted, audioIsLoading, asrEditorAudio,// Column ResizingleftColumnWidth, rightColumnWidth, isResizing,diff --git a/static/js/modules/composables/ui.js b/static/js/modules/composables/ui.jsindex 4bd53834..278e3f78 100644--- a/static/js/modules/composables/ui.js+++ b/static/js/modules/composables/ui.js@@ -11,6 +11,7 @@ export function useUI(state, utils, processedTranscription) {searchTipsExpanded, isMetadataExpanded, editingParticipants, editingMeetingDate,editingSummary, tempSummaryContent, summaryMarkdownEditorInstance,leftColumnWidth, rightColumnWidth, isResizing, playerVolume,+ audioIsPlaying, audioCurrentTime, audioDuration, audioIsMuted, audioIsLoading,editingNotes, tempNotesContent, transcriptionViewMode,notesMarkdownEditor, markdownEditorInstance, autoSaveTimer, csrfToken,summaryMarkdownEditor, recordingNotesEditor, recordingMarkdownEditorInstance,@@ -815,6 +816,115 @@ export function useUI(state, utils, processedTranscription) {localStorage.setItem('playerVolume', newVolume);};+ // --- Custom Audio Player Controls ---+ const getAudioElement = () => {+ // Try to find audio in right column (desktop) or detail view (mobile)+ return document.querySelector('#rightMainColumn audio') ||+ document.querySelector('.detail-view audio') ||+ document.querySelector('audio[ref="audioPlayerElement"]') ||+ document.querySelector('audio');+ };++ const toggleAudioPlayback = () => {+ const audio = getAudioElement();+ if (!audio) return;++ if (audio.paused) {+ audio.play();+ } else {+ audio.pause();+ }+ };++ const toggleAudioMute = () => {+ const audio = getAudioElement();+ if (!audio) return;++ audio.muted = !audio.muted;+ audioIsMuted.value = audio.muted;+ };++ const setAudioVolume = (volume) => {+ const audio = getAudioElement();+ if (!audio) return;++ audio.volume = Math.max(0, Math.min(1, volume));+ playerVolume.value = audio.volume;+ localStorage.setItem('playerVolume', audio.volume);++ if (audio.volume === 0) {+ audio.muted = true;+ audioIsMuted.value = true;+ } else if (audio.muted) {+ audio.muted = false;+ audioIsMuted.value = false;+ }+ };++ const seekAudioTo = (time) => {+ const audio = getAudioElement();+ if (!audio) return;++ audio.currentTime = Math.max(0, Math.min(time, audio.duration || 0));+ };++ const seekAudioByPercent = (percent) => {+ const audio = getAudioElement();+ if (!audio || !audio.duration) return;++ const time = (percent / 100) * audio.duration;+ audio.currentTime = time;+ };++ const handleAudioPlayPause = (event) => {+ audioIsPlaying.value = !event.target.paused;+ };++ const handleAudioLoadedMetadata = (event) => {+ audioDuration.value = event.target.duration || 0;+ audioIsLoading.value = false;+ };++ const handleAudioEnded = () => {+ audioIsPlaying.value = false;+ audioCurrentTime.value = 0;+ };++ const handleCustomAudioTimeUpdate = (event) => {+ audioCurrentTime.value = event.target.currentTime;+ // Also call the existing handler for segment tracking+ handleAudioTimeUpdate(event);+ };++ const handleAudioWaiting = () => {+ audioIsLoading.value = true;+ };++ const handleAudioCanPlay = () => {+ audioIsLoading.value = false;+ };++ const formatAudioTime = (seconds) => {+ if (!seconds || isNaN(seconds)) return '0:00';+ const mins = Math.floor(seconds / 60);+ const secs = Math.floor(seconds % 60);+ return `${mins}:${secs.toString().padStart(2, '0')}`;+ };++ const audioProgressPercent = computed(() => {+ if (!audioDuration.value) return 0;+ return (audioCurrentTime.value / audioDuration.value) * 100;+ });++ // Reset audio player state (called when recording changes)+ const resetAudioPlayerState = () => {+ audioIsPlaying.value = false;+ audioCurrentTime.value = 0;+ audioDuration.value = 0;+ audioIsMuted.value = false;+ audioIsLoading.value = false;+ };+// --- Active Segment Tracking ---const handleAudioTimeUpdate = (event) => {const transcription = processedTranscription.value;@@ -1249,9 +1359,10 @@ export function useUI(state, utils, processedTranscription) {followPlayerMode.value = savedFollowMode === 'true';}- // Watch for recording changes to reset active segment+ // Watch for recording changes to reset active segment and audio player statewatch(selectedRecording, () => {currentPlayingSegmentIndex.value = null;+ resetAudioPlayerState();});// Set up global click handler to close dropdowns when clicking outside@@ -1549,6 +1660,25 @@ export function useUI(state, utils, processedTranscription) {handleAudioTimeUpdate,toggleFollowPlayerMode,scrollToActiveSegment,+ // Custom audio player+ toggleAudioPlayback,+ toggleAudioMute,+ setAudioVolume,+ seekAudioTo,+ seekAudioByPercent,+ handleAudioPlayPause,+ handleAudioLoadedMetadata,+ handleAudioEnded,+ handleCustomAudioTimeUpdate,+ handleAudioWaiting,+ handleAudioCanPlay,+ formatAudioTime,+ audioProgressPercent,+ audioIsPlaying,+ audioCurrentTime,+ audioDuration,+ audioIsMuted,+ audioIsLoading,// Copy functionscopyTranscription,copySummary,diff --git a/static/js/modules/state/sharing.js b/static/js/modules/state/sharing.jsindex 6f3b1b30..436b581e 100644--- a/static/js/modules/state/sharing.js+++ b/static/js/modules/state/sharing.js@@ -28,6 +28,11 @@ export function createSharingState(ref, reactive) {// --- Audio Player State ---const playerVolume = ref(1.0);+ const audioIsPlaying = ref(false);+ const audioCurrentTime = ref(0);+ const audioDuration = ref(0);+ const audioIsMuted = ref(false);+ const audioIsLoading = ref(false);return {// Public sharing@@ -51,6 +56,11 @@ export function createSharingState(ref, reactive) {isLoadingAllUsers,// Audio player- playerVolume+ playerVolume,+ audioIsPlaying,+ audioCurrentTime,+ audioDuration,+ audioIsMuted,+ audioIsLoading};}diff --git a/templates/components/detail/audio-player.html b/templates/components/detail/audio-player.htmlindex a31c4d61..d030eaae 100644--- a/templates/components/detail/audio-player.html+++ b/templates/components/detail/audio-player.html@@ -1,29 +1,63 @@-<!-- Audio Player Component -->-<div class="bg-[var(--bg-secondary)] p-4 border-b border-[var(--border-primary)] flex-shrink-0">- <div class="audio-player-container">- <!-- Show message if audio has been deleted -->- <div v-if="selectedRecording.audio_deleted_at"- class="bg-[var(--bg-tertiary)] border border-[var(--border-primary)] text-[var(--text-muted)] px-4 py-3 rounded-lg flex items-center gap-2 text-sm">- <i class="fas fa-info-circle"></i>- <span v-text="t('help.audioDeletedMessage')"></span>- </div>- <!-- Show audio player if audio is available -->- <div v-else class="flex items-center gap-2">- <audio ref="audioPlayerElement"- controls- :src="'/audio/' + selectedRecording.id"- :volume="playerVolume"- @volumechange="onPlayerVolumeChange"- @timeupdate="handleAudioTimeUpdate"- class="flex-1">- Your browser does not support the audio element.- </audio>- <a :href="'/audio/' + selectedRecording.id + '?download=true'"- download- class="h-[36px] w-[36px] flex items-center justify-center rounded-lg bg-[var(--bg-tertiary)] hover:bg-[var(--bg-accent)] text-[var(--text-muted)] hover:text-white transition-all duration-200 flex-shrink-0 border border-[var(--border-secondary)] hover:border-[var(--border-focus)]"- :title="t('buttons.downloadAudio') || 'Download audio'">- <i class="fas fa-download text-sm"></i>- </a>+<!-- Audio Player Component (Mobile) -->+<div class="bg-[var(--bg-secondary)] px-4 py-3 border-b border-[var(--border-primary)] flex-shrink-0">+ <!-- Show message if audio has been deleted -->+ <div v-if="selectedRecording.audio_deleted_at"+ class="text-[var(--text-muted)] text-sm flex items-center gap-2">+ <i class="fas fa-info-circle"></i>+ <span v-text="t('help.audioDeletedMessage')"></span>+ </div>+ <!-- Custom Audio Player -->+ <div v-else class="flex items-center gap-3">+ <!-- Hidden audio element -->+ <audio ref="audioPlayerElement"+ :src="'/audio/' + selectedRecording.id"+ :volume="playerVolume"+ @play="handleAudioPlayPause"+ @pause="handleAudioPlayPause"+ @timeupdate="handleCustomAudioTimeUpdate"+ @loadedmetadata="handleAudioLoadedMetadata"+ @ended="handleAudioEnded"+ @waiting="handleAudioWaiting"+ @canplay="handleAudioCanPlay"+ 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>+ </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>++ <!-- 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></div></div>diff --git a/templates/components/detail/desktop-right-panel.html b/templates/components/detail/desktop-right-panel.htmlindex 98099358..56318bf6 100644--- a/templates/components/detail/desktop-right-panel.html+++ b/templates/components/detail/desktop-right-panel.html@@ -1,32 +1,71 @@<!-- Desktop Right Panel (Summary/Notes/Chat) --><div id="rightMainColumn" class="flex flex-col overflow-hidden" :style="{width: rightColumnWidth + '%'}">- <!-- Audio Player -->- <div class="bg-[var(--bg-secondary)] p-4 border-b border-[var(--border-primary)] flex-shrink-0">- <div class="audio-player-container">- <!-- Show message if audio has been deleted -->- <div v-if="selectedRecording.audio_deleted_at"- class="bg-[var(--bg-tertiary)] border border-[var(--border-primary)] text-[var(--text-muted)] px-4 py-3 rounded-lg flex items-center gap-2 text-sm">- <i class="fas fa-info-circle"></i>- <span v-text="t('help.audioDeletedMessage')"></span>+ <!-- Custom Audio Player -->+ <div class="bg-[var(--bg-secondary)] px-5 py-4 border-b border-[var(--border-primary)] flex-shrink-0">+ <!-- Show message if audio has been deleted -->+ <div v-if="selectedRecording.audio_deleted_at"+ class="text-[var(--text-muted)] text-sm flex items-center gap-2">+ <i class="fas fa-info-circle"></i>+ <span v-text="t('help.audioDeletedMessage')"></span>+ </div>+ <!-- Custom Audio Player -->+ <div v-else class="flex items-center gap-4">+ <!-- Hidden audio element -->+ <audio ref="audioPlayerElement"+ :src="'/audio/' + selectedRecording.id"+ :volume="playerVolume"+ @play="handleAudioPlayPause"+ @pause="handleAudioPlayPause"+ @timeupdate="handleCustomAudioTimeUpdate"+ @loadedmetadata="handleAudioLoadedMetadata"+ @ended="handleAudioEnded"+ @waiting="handleAudioWaiting"+ @canplay="handleAudioCanPlay"+ 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>++ <!-- Time Display -->+ <div class="flex flex-col items-end flex-shrink-0 leading-tight">+ <span class="text-sm text-[var(--text-primary)] font-mono">${ formatAudioTime(audioCurrentTime) }</span>+ <span class="text-xs text-[var(--text-muted)] font-mono">${ formatAudioTime(audioDuration) }</span></div>- <!-- Show audio player if audio is available -->- <div v-else class="flex items-center gap-2">- <audio ref="audioPlayerElement"- controls- :src="'/audio/' + selectedRecording.id"- :volume="playerVolume"- @volumechange="onPlayerVolumeChange"- @timeupdate="handleAudioTimeUpdate"- class="flex-1">- Your browser does not support the audio element.- </audio>- <a :href="'/audio/' + selectedRecording.id + '?download=true'"- download- class="h-[36px] w-[36px] flex items-center justify-center rounded-lg bg-[var(--bg-tertiary)] hover:bg-[var(--bg-accent)] text-[var(--text-muted)] hover:text-white transition-all duration-200 flex-shrink-0 border border-[var(--border-secondary)] hover:border-[var(--border-focus)]"- :title="t('buttons.downloadAudio') || 'Download audio'">- <i class="fas fa-download text-sm"></i>- </a>++ <!-- Progress Bar -->+ <div class="flex-1 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>+ </div>++ <!-- Volume Control -->+ <div class="flex items-center gap-2 flex-shrink-0">+ <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"+ :title="audioIsMuted ? 'Unmute' : 'Mute'">+ <i :class="audioIsMuted || playerVolume === 0 ? 'fas fa-volume-mute' : playerVolume < 0.5 ? 'fas fa-volume-down' : 'fas fa-volume-up'" class="text-base"></i>+ </button>+ <input type="range" min="0" max="1" step="0.05"+ :value="playerVolume"+ @input="(e) => setAudioVolume(parseFloat(e.target.value))"+ class="volume-slider w-20 h-1.5 cursor-pointer"></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"+ :title="t('buttons.downloadAudio') || 'Download audio'">+ <i class="fas fa-download text-base"></i>+ </a></div></div>