mirror of
https://github.com/gtsteffaniak/filebrowser.git
synced 2026-11-26 08:29:41 -05:00
convert AudioPanel and related files to composition api + ts and refactor lyrics
This commit is contained in:
7 files changed
+1225
-1251
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,306 @@
|
||||
<template>
|
||||
<div class="lyrics-view" :class="{ compact }">
|
||||
<FloatingActionButton
|
||||
v-if="syncedLyrics"
|
||||
v-bind="lockButtonProps"
|
||||
icon="lock"
|
||||
:icon-outlined="scrollLocked"
|
||||
size="small"
|
||||
:auto-hide="false"
|
||||
:label="lockLabel"
|
||||
@press="scrollLocked = !scrollLocked"
|
||||
/>
|
||||
<div ref="lyricsScrollable" class="lyrics-scrollable">
|
||||
<div v-if="lyrics.length" class="lyrics-list">
|
||||
<p v-if="meta" class="lyrics-meta-header" aria-hidden="true">{{ meta }}</p>
|
||||
<p
|
||||
v-for="(line, index) in lyrics"
|
||||
:key="index"
|
||||
:class="{ active: syncedLyrics && line.timestamp === lyrics[activeLyricIndex]?.timestamp, 'no-seek': !syncedLyrics }"
|
||||
class="lyric-line"
|
||||
@click.stop="syncedLyrics && seek(line.timestamp)"
|
||||
@keydown.enter.stop.prevent="syncedLyrics && seek(line.timestamp)"
|
||||
@keydown.space.stop.prevent="syncedLyrics && seek(line.timestamp)"
|
||||
:role="syncedLyrics ? 'button' : undefined"
|
||||
:tabindex="syncedLyrics ? 0 : undefined"
|
||||
:aria-label="syncedLyrics ? `Seek to ${line.text}` : undefined"
|
||||
>
|
||||
<template v-if="index === activeLyricIndex && line.words && line.words.length">
|
||||
<span
|
||||
v-for="(word, w) in line.words"
|
||||
:key="w"
|
||||
class="lyric-word"
|
||||
:class="{ sung: w <= activeWordIndex, current: w === activeWordIndex }"
|
||||
>{{ word.text }} </span>
|
||||
</template>
|
||||
<template v-else>{{ line.text }}</template>
|
||||
</p>
|
||||
</div>
|
||||
<div v-else class="no-lyrics">
|
||||
<i class="material-symbols">lyrics</i>
|
||||
<p>{{ t('player.noLyrics') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, onBeforeUnmount, onMounted, ref, useTemplateRef, watch } from "vue";
|
||||
import type Plyr from "plyr";
|
||||
import FloatingActionButton from "@/components/settings/FloatingActionButton.vue";
|
||||
import { useI18n } from "@/i18n/index.ts";
|
||||
import { isSyncedLyrics } from "@/utils/lyrics.ts";
|
||||
import type { LyricLines } from "@/utils/lyrics.ts";
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
lyrics?: LyricLines;
|
||||
/** the active line and word follow its current time, and clicking a line seeks it */
|
||||
player?: Plyr | null;
|
||||
/** tighter spacing, for the mobile view */
|
||||
compact?: boolean;
|
||||
}>(),
|
||||
{
|
||||
lyrics: () => [],
|
||||
player: null,
|
||||
compact: false,
|
||||
}
|
||||
);
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const lyricsScrollable = useTemplateRef<HTMLElement>("lyricsScrollable");
|
||||
|
||||
const activeLyricIndex = ref(-1);
|
||||
const activeWordIndex = ref(-1);
|
||||
const scrollLocked = ref(false);
|
||||
|
||||
const syncedLyrics = computed(() => isSyncedLyrics(props.lyrics));
|
||||
// "Title - Artist" shown above the lyrics from the [ti:] [ar:] tags on lyrics (if present)
|
||||
const meta = computed(() => [props.lyrics.lrcMeta?.title, props.lyrics.lrcMeta?.artist].filter(Boolean).join(" - "));
|
||||
const lockLabel = computed(() => (scrollLocked.value ? t("player.unlockLyrics") : t("player.lockLyrics")));
|
||||
const lockButtonProps = computed(() =>
|
||||
props.compact
|
||||
? { position: "bottom-right", offset: { bottom: "calc(env(safe-area-inset-bottom, 0px) + 6rem)" } }
|
||||
: { positionMode: "absolute", edgeOffset: { top: "0.5em", right: "0.5em" } }
|
||||
);
|
||||
|
||||
// Seek the player to the given timestamp (in milliseconds)
|
||||
function seek(timestampMs: number) {
|
||||
const player = props.player;
|
||||
if (player) player.currentTime = timestampMs / 1000;
|
||||
}
|
||||
|
||||
// Last item that has started by currentMs, scanning forward from the previous index
|
||||
// (-1 if none has). A previous index that is stale or already ahead of the time restarts the scan.
|
||||
function findActiveIndex(items: readonly { timestamp: number }[], from: number, currentMs: number) {
|
||||
let idx = from >= 0 && from < items.length && (items.at(from)?.timestamp ?? 0) <= currentMs ? from : -1;
|
||||
while (idx + 1 < items.length && (items.at(idx + 1)?.timestamp ?? Number.POSITIVE_INFINITY) <= currentMs) {
|
||||
idx++;
|
||||
}
|
||||
return idx;
|
||||
}
|
||||
|
||||
// Update the active lyric line (and the active word within it, for elrc) from the player time.
|
||||
function syncLyrics() {
|
||||
const player = props.player;
|
||||
if (!player || !syncedLyrics.value) return;
|
||||
const lyrics = props.lyrics;
|
||||
const currentMs = player.currentTime * 1000;
|
||||
const idx = findActiveIndex(lyrics, activeLyricIndex.value, currentMs);
|
||||
// lines sharing a timestamp are highlighted together, so point at the first of them
|
||||
let first = idx;
|
||||
while (first > 0 && lyrics.at(first - 1)?.timestamp === lyrics.at(idx)?.timestamp) {
|
||||
first--;
|
||||
}
|
||||
if (first !== activeLyricIndex.value) {
|
||||
activeLyricIndex.value = first;
|
||||
activeWordIndex.value = -1;
|
||||
}
|
||||
const words = first >= 0 ? lyrics.at(first)?.words : null;
|
||||
activeWordIndex.value = words?.length ? findActiveIndex(words, activeWordIndex.value, currentMs) : -1;
|
||||
}
|
||||
|
||||
function scrollToActiveLine() {
|
||||
if (scrollLocked.value) return;
|
||||
const active = lyricsScrollable.value?.querySelector(".lyric-line.active");
|
||||
if (active) {
|
||||
active.scrollIntoView({ behavior: "smooth", block: "center" });
|
||||
}
|
||||
}
|
||||
|
||||
async function scrollAfterRender() {
|
||||
await nextTick();
|
||||
scrollToActiveLine();
|
||||
}
|
||||
|
||||
// a destroyed player throws on both, and there is nothing left to listen to
|
||||
function listen(player: Plyr | null | undefined, subscribe: boolean) {
|
||||
try {
|
||||
if (subscribe) player?.on("timeupdate", syncLyrics);
|
||||
else player?.off("timeupdate", syncLyrics);
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.player,
|
||||
(player, oldPlayer) => {
|
||||
listen(oldPlayer, false);
|
||||
listen(player, true);
|
||||
syncLyrics();
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
watch(
|
||||
() => props.lyrics,
|
||||
() => {
|
||||
activeLyricIndex.value = -1;
|
||||
activeWordIndex.value = -1;
|
||||
syncLyrics();
|
||||
scrollAfterRender();
|
||||
}
|
||||
);
|
||||
|
||||
watch(activeLyricIndex, scrollAfterRender);
|
||||
watch(scrollLocked, (locked) => {
|
||||
if (!locked) scrollAfterRender();
|
||||
});
|
||||
|
||||
onMounted(scrollToActiveLine);
|
||||
onBeforeUnmount(() => listen(props.player, false));
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.lyrics-view {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.lyrics-scrollable {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
min-height: 0;
|
||||
text-align: center;
|
||||
color: var(--textPrimary);
|
||||
scrollbar-width: none;
|
||||
}
|
||||
|
||||
.lyrics-scrollable::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.lyrics-list {
|
||||
padding-top: 1em;
|
||||
padding-bottom: 1em;
|
||||
}
|
||||
|
||||
.lyrics-meta-header {
|
||||
padding: 0 0 0.6em;
|
||||
margin: 0;
|
||||
opacity: 0.55;
|
||||
font-size: 0.8rem;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.02em;
|
||||
text-transform: uppercase;
|
||||
cursor: default;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.lyric-line {
|
||||
padding: 0.5em 0;
|
||||
opacity: 0.6;
|
||||
cursor: pointer;
|
||||
transition: opacity 0.25s ease, color 0.25s ease, font-size 0.25s ease, transform 0.25s ease;
|
||||
transform: scale(1);
|
||||
transform-origin: center;
|
||||
overflow-wrap: break-word;
|
||||
font-size: 1.15rem;
|
||||
}
|
||||
|
||||
.lyric-line:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.lyric-line.active {
|
||||
opacity: 1;
|
||||
font-weight: 700;
|
||||
color: var(--primaryColor);
|
||||
font-size: 1.33rem;
|
||||
animation: lyric-line-in 0.3s ease;
|
||||
}
|
||||
|
||||
.lyric-line.no-seek {
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
@keyframes lyric-line-in {
|
||||
0% { transform: scale(0.98); }
|
||||
100% { transform: scale(1); }
|
||||
}
|
||||
|
||||
.lyric-word {
|
||||
display: inline-block;
|
||||
opacity: 0.4;
|
||||
transform: scale(1);
|
||||
transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.25, 0.8, 0.25, 1);
|
||||
}
|
||||
|
||||
.lyric-word.sung {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.lyric-word.current {
|
||||
transform: scale(1.05);
|
||||
}
|
||||
|
||||
.no-lyrics {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 100%;
|
||||
color: var(--textSecondary);
|
||||
gap: 0.5em;
|
||||
}
|
||||
|
||||
.no-lyrics i {
|
||||
font-size: 3rem;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
/* Mobile */
|
||||
.compact .lyrics-scrollable {
|
||||
padding: 0 1em;
|
||||
}
|
||||
|
||||
.compact .lyrics-list {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.compact .lyrics-meta-header {
|
||||
padding-top: 0.2em;
|
||||
}
|
||||
|
||||
.compact .lyric-line {
|
||||
padding: 0.2em 0;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.compact .lyric-line:hover {
|
||||
opacity: 0.85;
|
||||
}
|
||||
|
||||
.compact .lyric-line.active {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.compact .lyric-line:first-child {
|
||||
padding-top: 0;
|
||||
}
|
||||
</style>
|
||||
@@ -2,8 +2,8 @@
|
||||
<div class="card-content visualizer-settings-content settings-items">
|
||||
<div class="setting-row item">
|
||||
<div class="setting-label">
|
||||
<label for="vis-bar-count">{{ $t("player.visualizer.barCount") }}</label>
|
||||
<HelpTooltipIcon :text="$t('player.visualizer.barCountDescription')" />
|
||||
<label for="vis-bar-count">{{ t("player.visualizer.barCount") }}</label>
|
||||
<HelpTooltipIcon :text="t('player.visualizer.barCountDescription')" />
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<input
|
||||
@@ -13,53 +13,53 @@
|
||||
v-model.number="barCount"
|
||||
min="2"
|
||||
max="200"
|
||||
:aria-label="$t('player.visualizer.barCount')"
|
||||
:aria-label="t('player.visualizer.barCount')"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="setting-row item">
|
||||
<div class="setting-label">
|
||||
<span id="vis-fft-size-label">{{ $t("player.visualizer.fftSize") }}</span>
|
||||
<HelpTooltipIcon :text="$t('player.visualizer.fftSizeDescription')" />
|
||||
<span id="vis-fft-size-label">{{ t("player.visualizer.fftSize") }}</span>
|
||||
<HelpTooltipIcon :text="t('player.visualizer.fftSizeDescription')" />
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<ExpandDropdown
|
||||
:options="fftSizeOptions"
|
||||
v-model="fftSize"
|
||||
:aria-label="$t('player.visualizer.fftSize')"
|
||||
:aria-label="t('player.visualizer.fftSize')"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="setting-row item">
|
||||
<div class="setting-label">
|
||||
<span id="vis-min-freq-label">{{ $t("player.visualizer.minFrequency") }}</span>
|
||||
<HelpTooltipIcon :text="$t('player.visualizer.minFrequencyDescription')" />
|
||||
<span id="vis-min-freq-label">{{ t("player.visualizer.minFrequency") }}</span>
|
||||
<HelpTooltipIcon :text="t('player.visualizer.minFrequencyDescription')" />
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<ExpandDropdown
|
||||
:options="minFrequencyOptions"
|
||||
v-model="minFrequency"
|
||||
:aria-label="$t('player.visualizer.minFrequency')"
|
||||
:aria-label="t('player.visualizer.minFrequency')"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="setting-row item">
|
||||
<div class="setting-label">
|
||||
<span id="vis-max-freq-label">{{ $t("player.visualizer.maxFrequency") }}</span>
|
||||
<HelpTooltipIcon :text="$t('player.visualizer.maxFrequencyDescription')" />
|
||||
<span id="vis-max-freq-label">{{ t("player.visualizer.maxFrequency") }}</span>
|
||||
<HelpTooltipIcon :text="t('player.visualizer.maxFrequencyDescription')" />
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<ExpandDropdown
|
||||
:options="maxFrequencyOptions"
|
||||
v-model="maxFrequency"
|
||||
:aria-label="$t('player.visualizer.maxFrequency')"
|
||||
:aria-label="t('player.visualizer.maxFrequency')"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="setting-row slider-setting item">
|
||||
<div class="setting-label">
|
||||
<label for="vis-smoothing">{{ $t("player.visualizer.smoothing") }}</label>
|
||||
<HelpTooltipIcon :text="$t('player.visualizer.smoothingDescription')" />
|
||||
<label for="vis-smoothing">{{ t("player.visualizer.smoothing") }}</label>
|
||||
<HelpTooltipIcon :text="t('player.visualizer.smoothingDescription')" />
|
||||
</div>
|
||||
<div class="setting-control slider-setting-value">
|
||||
<input id="vis-smoothing" type="range" min="0" max="1" step="0.01" v-model.number="smoothing" />
|
||||
@@ -68,8 +68,8 @@
|
||||
</div>
|
||||
<div class="setting-row slider-setting item">
|
||||
<div class="setting-label">
|
||||
<label for="vis-min-db">{{ $t("player.visualizer.minDecibels") }}</label>
|
||||
<HelpTooltipIcon :text="$t('player.visualizer.minDecibelsDescription')" />
|
||||
<label for="vis-min-db">{{ t("player.visualizer.minDecibels") }}</label>
|
||||
<HelpTooltipIcon :text="t('player.visualizer.minDecibelsDescription')" />
|
||||
</div>
|
||||
<div class="setting-control slider-setting-value">
|
||||
<input id="vis-min-db" type="range" min="-120" max="-60" step="1" v-model.number="minDecibels" />
|
||||
@@ -78,8 +78,8 @@
|
||||
</div>
|
||||
<div class="setting-row slider-setting item">
|
||||
<div class="setting-label">
|
||||
<label for="vis-max-db">{{ $t("player.visualizer.maxDecibels") }}</label>
|
||||
<HelpTooltipIcon :text="$t('player.visualizer.maxDecibelsDescription')" />
|
||||
<label for="vis-max-db">{{ t("player.visualizer.maxDecibels") }}</label>
|
||||
<HelpTooltipIcon :text="t('player.visualizer.maxDecibelsDescription')" />
|
||||
</div>
|
||||
<div class="setting-control slider-setting-value">
|
||||
<input id="vis-max-db" type="range" min="-40" max="20" step="1" v-model.number="maxDecibels" />
|
||||
@@ -88,14 +88,14 @@
|
||||
</div>
|
||||
<ToggleSwitch
|
||||
class="item"
|
||||
:name="$t('player.visualizer.showScales')"
|
||||
:description="$t('player.visualizer.showScalesDescription')"
|
||||
:name="t('player.visualizer.showScales')"
|
||||
:description="t('player.visualizer.showScalesDescription')"
|
||||
v-model="showScales"
|
||||
/>
|
||||
<ToggleSwitch
|
||||
class="item"
|
||||
:name="$t('player.visualizer.showPeaks')"
|
||||
:description="$t('player.visualizer.showPeaksDescription')"
|
||||
:name="t('player.visualizer.showPeaks')"
|
||||
:description="t('player.visualizer.showPeaksDescription')"
|
||||
v-model="showPeaks"
|
||||
/>
|
||||
</div>
|
||||
@@ -104,95 +104,69 @@
|
||||
type="button"
|
||||
class="button button--flat button--grey"
|
||||
@click="resetVisualizerConfig"
|
||||
:aria-label="$t('player.visualizer.resetDefaults')"
|
||||
:title="$t('player.visualizer.resetDefaults')"
|
||||
> {{ $t("player.visualizer.resetDefaults") }}
|
||||
:aria-label="t('player.visualizer.resetDefaults')"
|
||||
:title="t('player.visualizer.resetDefaults')"
|
||||
> {{ t("player.visualizer.resetDefaults") }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="button button--flat"
|
||||
@click="closeTopPrompt"
|
||||
:aria-label="$t('general.ok')"
|
||||
:title="$t('general.ok')"
|
||||
> {{ $t("general.ok") }}
|
||||
:aria-label="t('general.ok')"
|
||||
:title="t('general.ok')"
|
||||
> {{ t("general.ok") }}
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
<script setup lang="ts">
|
||||
import { computed } from "vue";
|
||||
import HelpTooltipIcon from "@/components/HelpTooltipIcon.vue";
|
||||
import { useI18n } from "@/i18n/index.ts";
|
||||
import { mutations } from "@/store/index.ts";
|
||||
import { visualizerConfig, saveVisualizerConfig, resetVisualizerConfig } from "@/utils/visualizerConfig.js";
|
||||
import { visualizerConfig, saveVisualizerConfig, resetVisualizerConfig, type VisualizerConfig } from "@/utils/visualizerConfig.ts";
|
||||
import ExpandDropdown from "@/components/settings/ExpandDropdown.vue";
|
||||
import ToggleSwitch from "@/components/settings/ToggleSwitch.vue";
|
||||
|
||||
function freqOptions(values) {
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
promptId?: string | number | null;
|
||||
}>(),
|
||||
{ promptId: null },
|
||||
);
|
||||
|
||||
defineOptions({ name: "VisualizerSettings" });
|
||||
|
||||
function freqOptions(values: number[]) {
|
||||
return values.map((value) => ({ value, label: `${value} Hz` }));
|
||||
}
|
||||
|
||||
export default {
|
||||
name: "VisualizerSettings",
|
||||
components: { HelpTooltipIcon, ExpandDropdown, ToggleSwitch },
|
||||
props: {
|
||||
promptId: { type: [String, Number], default: null },
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
fftSizeOptions: [1024, 2048, 4096, 8192, 16384, 32768].map((value) => ({ value, label: `${value}` })),
|
||||
minFrequencyOptions: freqOptions([20, 30, 40, 50]),
|
||||
maxFrequencyOptions: freqOptions([8000, 10000, 15000, 20000, 22050]),
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
barCount: {
|
||||
get() { return visualizerConfig.barCount; },
|
||||
set(value) {
|
||||
const clamped = Math.min(200, Math.max(2, Math.round(value) || 0));
|
||||
saveVisualizerConfig({ barCount: clamped });
|
||||
},
|
||||
},
|
||||
fftSize: {
|
||||
get() { return visualizerConfig.fftSize; },
|
||||
set(value) { saveVisualizerConfig({ fftSize: Number(value) }); },
|
||||
},
|
||||
minFrequency: {
|
||||
get() { return visualizerConfig.minFrequency; },
|
||||
set(value) { saveVisualizerConfig({ minFrequency: Number(value) }); },
|
||||
},
|
||||
maxFrequency: {
|
||||
get() { return visualizerConfig.maxFrequency; },
|
||||
set(value) { saveVisualizerConfig({ maxFrequency: Number(value) }); },
|
||||
},
|
||||
smoothing: {
|
||||
get() { return visualizerConfig.smoothing; },
|
||||
set(value) { saveVisualizerConfig({ smoothing: value }); },
|
||||
},
|
||||
minDecibels: {
|
||||
get() { return visualizerConfig.minDecibels; },
|
||||
set(value) { saveVisualizerConfig({ minDecibels: value }); },
|
||||
},
|
||||
maxDecibels: {
|
||||
get() { return visualizerConfig.maxDecibels; },
|
||||
set(value) { saveVisualizerConfig({ maxDecibels: value }); },
|
||||
},
|
||||
showScales: {
|
||||
get() { return visualizerConfig.showScales; },
|
||||
set(value) { saveVisualizerConfig({ showScales: value }); },
|
||||
},
|
||||
showPeaks: {
|
||||
get() { return visualizerConfig.showPeaks; },
|
||||
set(value) { saveVisualizerConfig({ showPeaks: value }); },
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
closeTopPrompt() {
|
||||
mutations.closeTopPrompt();
|
||||
},
|
||||
resetVisualizerConfig() {
|
||||
resetVisualizerConfig();
|
||||
},
|
||||
},
|
||||
};
|
||||
const { t } = useI18n();
|
||||
|
||||
const fftSizeOptions = [1024, 2048, 4096, 8192, 16384, 32768].map((value) => ({ value, label: `${value}` }));
|
||||
const minFrequencyOptions = freqOptions([20, 30, 40, 50]);
|
||||
const maxFrequencyOptions = freqOptions([8000, 10000, 15000, 20000, 22050]);
|
||||
|
||||
function configRef<K extends keyof VisualizerConfig>(key: K, parse: (value: unknown) => VisualizerConfig[K] = (value) => value as VisualizerConfig[K]) {
|
||||
return computed<VisualizerConfig[K]>({
|
||||
get: () => visualizerConfig[key],
|
||||
set: (value) => saveVisualizerConfig({ [key]: parse(value) } as Partial<VisualizerConfig>),
|
||||
});
|
||||
}
|
||||
|
||||
const barCount = configRef("barCount", (value) => Math.min(200, Math.max(2, Math.round(Number(value)) || 0)));
|
||||
const fftSize = configRef("fftSize", Number);
|
||||
const minFrequency = configRef("minFrequency", Number);
|
||||
const maxFrequency = configRef("maxFrequency", Number);
|
||||
const smoothing = configRef("smoothing");
|
||||
const minDecibels = configRef("minDecibels");
|
||||
const maxDecibels = configRef("maxDecibels");
|
||||
const showScales = configRef("showScales");
|
||||
const showPeaks = configRef("showPeaks");
|
||||
|
||||
function closeTopPrompt() {
|
||||
mutations.closeTopPrompt();
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -21,6 +21,10 @@ export interface LyricsMeta {
|
||||
|
||||
export type LyricLines = LyricLine[] & { lrcMeta?: LyricsMeta };
|
||||
|
||||
export function isSyncedLyrics(lyrics: LyricLine[]): boolean {
|
||||
return lyrics.length > 0 && !lyrics.every((line) => line.timestamp === 0);
|
||||
}
|
||||
|
||||
const INLINE_TAG_RE = /<[^>]*>/g;
|
||||
|
||||
// Lines that have brackets like [ti: Title] - unlike the timestamps that are like
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
import { reactive } from 'vue';
|
||||
|
||||
const STORAGE_KEY = 'visualizerConfig';
|
||||
|
||||
const DEFAULTS = {
|
||||
barCount: 60,
|
||||
smoothing: 0.92,
|
||||
fftSize: 8192,
|
||||
minFrequency: 20,
|
||||
maxFrequency: 20000,
|
||||
minDecibels: -70,
|
||||
maxDecibels: 0,
|
||||
showScales: true,
|
||||
showPeaks: true,
|
||||
};
|
||||
|
||||
function load() {
|
||||
try {
|
||||
const stored = localStorage.getItem(STORAGE_KEY);
|
||||
if (!stored) return { ...DEFAULTS };
|
||||
return { ...DEFAULTS, ...JSON.parse(stored) };
|
||||
} catch (_) {
|
||||
return { ...DEFAULTS };
|
||||
}
|
||||
}
|
||||
|
||||
function persist() {
|
||||
try {
|
||||
localStorage.setItem(STORAGE_KEY, JSON.stringify(visualizerConfig));
|
||||
} catch (_) { /* ignore */ }
|
||||
}
|
||||
|
||||
export const visualizerConfig = reactive(load());
|
||||
|
||||
export function saveVisualizerConfig(partial) {
|
||||
Object.assign(visualizerConfig, partial);
|
||||
persist();
|
||||
}
|
||||
|
||||
export function resetVisualizerConfig() {
|
||||
Object.assign(visualizerConfig, DEFAULTS);
|
||||
persist();
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
import { reactive } from "vue";
|
||||
|
||||
export interface VisualizerConfig {
|
||||
/** number of bars (split between the L/R channels) */
|
||||
barCount: number;
|
||||
/** higher = smoother motion, but if set too high will look a bit slow */
|
||||
smoothing: number;
|
||||
/** FFT size (must be a power of two). Larger = better frequency but slower */
|
||||
fftSize: number;
|
||||
/** Hz - lowest frequency shown */
|
||||
minFrequency: number;
|
||||
/** Hz - highest frequency shown */
|
||||
maxFrequency: number;
|
||||
/** dBFS - the quietest level that still shows as a bar */
|
||||
minDecibels: number;
|
||||
/** dBFS - the loudest level before clipping */
|
||||
maxDecibels: number;
|
||||
/** show axis labels and grid lines */
|
||||
showScales: boolean;
|
||||
/** show peak indicators above the bars */
|
||||
showPeaks: boolean;
|
||||
}
|
||||
|
||||
const STORAGE_KEY = "visualizerConfig";
|
||||
|
||||
const DEFAULTS: Readonly<VisualizerConfig> = {
|
||||
barCount: 60,
|
||||
smoothing: 0.92,
|
||||
fftSize: 8192,
|
||||
minFrequency: 20,
|
||||
maxFrequency: 20000,
|
||||
minDecibels: -70,
|
||||
maxDecibels: 0,
|
||||
showScales: true,
|
||||
showPeaks: true,
|
||||
};
|
||||
|
||||
function sanitize(value: Partial<VisualizerConfig> | null): Partial<VisualizerConfig> {
|
||||
const valid: Partial<VisualizerConfig> = {};
|
||||
if (typeof value !== "object" || value === null) return valid;
|
||||
for (const key of Object.keys(DEFAULTS) as (keyof VisualizerConfig)[]) {
|
||||
const candidate = value[key];
|
||||
if (typeof candidate !== typeof DEFAULTS[key]) continue;
|
||||
if (typeof candidate === "number" && !Number.isFinite(candidate)) continue;
|
||||
Object.assign(valid, { [key]: candidate });
|
||||
}
|
||||
return valid;
|
||||
}
|
||||
|
||||
function load(): VisualizerConfig {
|
||||
try {
|
||||
const stored = localStorage.getItem(STORAGE_KEY);
|
||||
if (!stored) return { ...DEFAULTS };
|
||||
return { ...DEFAULTS, ...sanitize(JSON.parse(stored)) };
|
||||
} catch {
|
||||
return { ...DEFAULTS };
|
||||
}
|
||||
}
|
||||
|
||||
function persist() {
|
||||
try {
|
||||
localStorage.setItem(STORAGE_KEY, JSON.stringify(visualizerConfig));
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
|
||||
export const visualizerConfig: VisualizerConfig = reactive(load());
|
||||
|
||||
export function saveVisualizerConfig(partial: Partial<VisualizerConfig>) {
|
||||
Object.assign(visualizerConfig, sanitize(partial));
|
||||
persist();
|
||||
}
|
||||
|
||||
export function resetVisualizerConfig() {
|
||||
Object.assign(visualizerConfig, DEFAULTS);
|
||||
persist();
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
v-if="previewType === 'audio'"
|
||||
ref="audioPlayerGestureRoot"
|
||||
class="audio-player-container audio-player-container--plyr-gestures"
|
||||
:class="{ 'audio-player-container--lyrics-open': isMobile && showMobileLyrics && lyrics.length }"
|
||||
:class="{ 'audio-player-container--lyrics-open': mobileLyricsActive }"
|
||||
>
|
||||
<!-- Desktop panel button, will auto‑hide only when panel is closed -->
|
||||
<FloatingActionButton
|
||||
@@ -62,54 +62,33 @@
|
||||
<AudioPanel
|
||||
v-if="!isMobile && showDesktopPanel"
|
||||
:lyrics="lyrics"
|
||||
:lyrics-meta="lyricsMeta"
|
||||
:active-lyric-index="activeLyricIndex"
|
||||
:active-word-index="activeWordIndex"
|
||||
:player="player"
|
||||
:audio-context="audioContext"
|
||||
:audio-source="audioSource"
|
||||
class="lyrics-panel"
|
||||
@seek="seekToLyric"
|
||||
@needs-audio-graph="setupAudioVisualizer"
|
||||
/>
|
||||
</Transition>
|
||||
</div>
|
||||
|
||||
<!-- Mobile inline lyrics -->
|
||||
<div v-if="isMobile && showMobileLyrics && lyrics.length" class="lyrics-mobile">
|
||||
<!-- Scrollable area -->
|
||||
<div class="lyrics-mobile-scrollable" ref="lyricsMobileScrollable">
|
||||
<p v-if="lyricsMeta" class="lyrics-meta-header" aria-hidden="true">{{ lyricsMeta }}</p>
|
||||
<p
|
||||
v-for="(line, i) in lyrics"
|
||||
:key="i"
|
||||
:class="{ active: syncedLyrics && lyrics[i].timestamp === lyrics[activeLyricIndex]?.timestamp }"
|
||||
class="lyric-line"
|
||||
@click.stop="syncedLyrics && seekToLyric(line.timestamp)"
|
||||
tabindex="0"
|
||||
role="button"
|
||||
:aria-label="syncedLyrics ? `Seek to ${line.text}` : undefined"
|
||||
>
|
||||
<template v-if="i === activeLyricIndex && line.words && line.words.length">
|
||||
<span
|
||||
v-for="(word, w) in line.words"
|
||||
:key="w"
|
||||
class="lyric-word"
|
||||
:class="{ sung: w <= activeWordIndex, current: w === activeWordIndex }"
|
||||
>{{ word.text }} </span>
|
||||
</template>
|
||||
<template v-else>{{ line.text }}</template>
|
||||
</p>
|
||||
<template v-if="isMobile && lyrics.length">
|
||||
<FloatingActionButton
|
||||
icon="lyrics"
|
||||
position="top-left"
|
||||
zone-height="8.5em"
|
||||
group="plyr-controls"
|
||||
:label="$t('player.toggleLyrics')"
|
||||
@press="showMobileLyrics = !showMobileLyrics"
|
||||
/>
|
||||
<div v-if="showMobileLyrics" class="lyrics-mobile">
|
||||
<LyricsList compact :lyrics="lyrics" :player="player" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
<!-- Audio controls -->
|
||||
<div class="audio-controls-container">
|
||||
<div class="plyr-audio-container">
|
||||
<audio :src="raw" :type="req.type" :autoplay="shouldAutoplay" @play="handlePlay" ref="audioElement"></audio>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Double‑tap / seek feedback overlay -->
|
||||
<div
|
||||
class="video-skip-feedback-layer"
|
||||
@@ -123,7 +102,6 @@
|
||||
<i :key="skipFeedbackKey" class="material-symbols video-skip-feedback-layer__icon">{{ skipFeedbackIcon }}</i>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Video with plyr -->
|
||||
<div
|
||||
v-else-if="previewType === 'video'"
|
||||
@@ -171,7 +149,6 @@
|
||||
<i :key="skipFeedbackKey" class="material-symbols video-skip-feedback-layer__icon">{{ skipFeedbackIcon }}</i>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Right detection zone – always for video/mobile audio queue button & desktop panel toggle -->
|
||||
<FloatingActionButton
|
||||
v-if="showQueueButton"
|
||||
@@ -181,31 +158,6 @@
|
||||
@press="showQueuePrompt"
|
||||
:label="queueButtonLabel"
|
||||
/>
|
||||
|
||||
<!-- Lyrics button (left side) – only on mobile when lyrics exist -->
|
||||
<FloatingActionButton
|
||||
v-if="isMobile && lyrics.length"
|
||||
icon="lyrics"
|
||||
position="top-left"
|
||||
zone-height="8.5em"
|
||||
group="plyr-controls"
|
||||
@press="showMobileLyrics = !showMobileLyrics"
|
||||
:label="lyricsToggleLabel"
|
||||
/>
|
||||
|
||||
<!-- Lyrics scroll lock (mobile, bottom‑right) – visible while lyrics overlay is open -->
|
||||
<FloatingActionButton
|
||||
v-if="isMobile && previewType === 'audio' && showMobileLyrics && lyrics.length && syncedLyrics"
|
||||
icon="lock"
|
||||
:icon-outlined="mobileLyricsScrollLocked"
|
||||
position="bottom-right"
|
||||
size="small"
|
||||
:offset="{ bottom: 'calc(env(safe-area-inset-bottom, 0px) + 6rem)' }"
|
||||
:auto-hide="false"
|
||||
@press="mobileLyricsScrollLocked = !mobileLyricsScrollLocked"
|
||||
:label="mobileLyricsLockToggleLabel"
|
||||
/>
|
||||
|
||||
<!-- Toast when you change playback modes in the media player -->
|
||||
<div :class="['playback-toast', toastVisible ? 'visible' : '']">
|
||||
<!-- Loop icon for "single playback", "loop single file" and "loop all files" -->
|
||||
@@ -243,6 +195,7 @@ import {
|
||||
import { getTypeFromMime } from '@/utils/files.js';
|
||||
import { buildItemUrl, removeTrailingSlash } from '@/utils/url.js';
|
||||
import AudioPanel from "@/components/files/AudioPanel.vue";
|
||||
import LyricsList from "@/components/files/LyricsList.vue";
|
||||
import { getters, mutations, state } from "@/store/index.ts";
|
||||
import { getObjectProperty } from '@/utils/object.js';
|
||||
import { globalVars } from "@/utils/constants.ts";
|
||||
@@ -330,6 +283,7 @@ export default {
|
||||
name: "plyrViewer",
|
||||
components: {
|
||||
AudioPanel,
|
||||
LyricsList,
|
||||
LoadingSpinner,
|
||||
FloatingActionButton,
|
||||
},
|
||||
@@ -391,15 +345,12 @@ export default {
|
||||
albumArtSize: Number.parseFloat(sessionStorage.getItem('plyrAlbumArtSize')) || 24,
|
||||
isHovering: false, // Track hover state
|
||||
|
||||
// Lyrics
|
||||
activeLyricIndex: -1,
|
||||
activeWordIndex: -1,
|
||||
doubleTapSeekCleanup: null,
|
||||
rewindForwardFeedback: null,
|
||||
mobileLyricsScrollLocked: false,
|
||||
|
||||
// Audio Visualizer
|
||||
audioContext: null,
|
||||
mediaGraph: null,
|
||||
audioSource: null,
|
||||
audioGraphInitialized: false,
|
||||
|
||||
@@ -538,30 +489,8 @@ export default {
|
||||
albumArtSize(val) {
|
||||
sessionStorage.setItem('plyrAlbumArtSize', val.toString());
|
||||
},
|
||||
async activeLyricIndex() {
|
||||
if (this.showMobileLyrics && this.isMobile) {
|
||||
await this.$nextTick();
|
||||
this.scrollMobileLyrics();
|
||||
}
|
||||
},
|
||||
lyrics(newLyrics, oldLyrics) {
|
||||
if (newLyrics !== oldLyrics) {
|
||||
this.activeLyricIndex = -1;
|
||||
this.activeWordIndex = -1;
|
||||
}
|
||||
},
|
||||
async mobileLyricsScrollLocked(val) {
|
||||
if (!val && this.showMobileLyrics && this.lyrics.length) {
|
||||
await this.$nextTick();
|
||||
this.scrollMobileLyrics();
|
||||
}
|
||||
},
|
||||
async showMobileLyrics(val) {
|
||||
showMobileLyrics(val) {
|
||||
sessionStorage.setItem('plyrShowMobileLyrics', val ? '1' : '0');
|
||||
if (val && this.lyrics.length) {
|
||||
await this.$nextTick();
|
||||
this.scrollMobileLyrics();
|
||||
}
|
||||
},
|
||||
shouldTogglePlayPause(newVal, oldVal) {
|
||||
if (newVal !== oldVal) {
|
||||
@@ -691,12 +620,6 @@ export default {
|
||||
queueButtonLabel() {
|
||||
return this.$t('player.QueueButtonHint');
|
||||
},
|
||||
lyricsToggleLabel() {
|
||||
return this.$t('player.toggleLyrics');
|
||||
},
|
||||
mobileLyricsLockToggleLabel() {
|
||||
return this.mobileLyricsScrollLocked ? this.$t('player.unlockLyrics') : this.$t('player.lockLyrics');
|
||||
},
|
||||
showQueueButton() {
|
||||
if (this.previewType === 'video') {
|
||||
return !this.isFullscreen;
|
||||
@@ -707,7 +630,7 @@ export default {
|
||||
return this.isMobile && this.showMobileLyrics && this.lyrics.length > 0;
|
||||
},
|
||||
displayArtSize() {
|
||||
if (this.isMobile && this.showMobileLyrics && this.lyrics.length) {
|
||||
if (this.mobileLyricsActive) {
|
||||
return 5;
|
||||
}
|
||||
return this.albumArtSize;
|
||||
@@ -789,16 +712,6 @@ export default {
|
||||
isMobile() {
|
||||
return getters.isMobile();
|
||||
},
|
||||
syncedLyrics() {
|
||||
return this.lyrics.length > 0 && !this.lyrics.every(line => line.timestamp === 0);
|
||||
},
|
||||
// "Title - Artist" shown above the lyrics from the [ti:] [ar:] tags on lyrics (if present)
|
||||
lyricsMeta() {
|
||||
const lyricsTitle = this.lyrics?.lrcMeta?.title;
|
||||
const lyricsArtist = this.lyrics?.lrcMeta?.artist;
|
||||
if (lyricsTitle && lyricsArtist) return `${lyricsTitle} - ${lyricsArtist}`;
|
||||
return lyricsTitle || lyricsArtist || '';
|
||||
},
|
||||
scrubPreviewEnabled() {
|
||||
return (
|
||||
this.previewType === 'video'
|
||||
@@ -1046,6 +959,7 @@ export default {
|
||||
try {
|
||||
this.destroyPlyr();
|
||||
} finally {
|
||||
this.cleanupAudioVisualizer({ close: true });
|
||||
this.clearMediaSession();
|
||||
document.removeEventListener('keydown', this.handleKeydown);
|
||||
window.removeEventListener('pagehide', this.onPageHide);
|
||||
@@ -1054,7 +968,7 @@ export default {
|
||||
methods: {
|
||||
onPageHide(event) {
|
||||
if (event.persisted) return;
|
||||
this.cleanupAudioVisualizer(); // to stop the visualizer when viewing another browser tab
|
||||
this.cleanupAudioVisualizer({ close: true });
|
||||
this.teardownTranscodePlayback({ stopSession: true, keepalive: true });
|
||||
this.stopMediaElement();
|
||||
},
|
||||
@@ -1345,22 +1259,21 @@ export default {
|
||||
this.loopButtons = null;
|
||||
this.loopValueSpan = null;
|
||||
},
|
||||
cleanupAudioVisualizer() {
|
||||
if (this.audioSource) {
|
||||
try { this.audioSource.disconnect(); } catch (_) { /* ignore */ }
|
||||
this.audioSource = null;
|
||||
}
|
||||
if (this.audioContext) {
|
||||
const context = this.audioContext;
|
||||
try {
|
||||
const closed = context.close();
|
||||
if (closed?.catch) closed.catch(() => {});
|
||||
} catch (_) {
|
||||
/* ignore */
|
||||
}
|
||||
this.audioContext = null;
|
||||
}
|
||||
cleanupAudioVisualizer({ close = false } = {}) {
|
||||
this.audioSource = null;
|
||||
this.audioContext = null;
|
||||
this.audioGraphInitialized = false;
|
||||
if (close) {
|
||||
this.closeMediaGraph(this.mediaGraph);
|
||||
this.mediaGraph = null;
|
||||
}
|
||||
},
|
||||
closeMediaGraph(graph) {
|
||||
try {
|
||||
graph?.context.close().catch(() => {});
|
||||
} catch (_) {
|
||||
/* ignore */
|
||||
}
|
||||
},
|
||||
togglePlayPause() {
|
||||
if (this.plyrTeardownDone) {
|
||||
@@ -1549,72 +1462,6 @@ export default {
|
||||
isShare: getters.isShare()
|
||||
});
|
||||
},
|
||||
// Seek the player to the given timestamp (in milliseconds)
|
||||
seekToLyric(timestampMs) {
|
||||
if (!this.player) return;
|
||||
this.player.currentTime = timestampMs / 1000;
|
||||
},
|
||||
// Update active lyric line based on current player time.
|
||||
syncLyrics() {
|
||||
if (!this.lyrics.length || !this.syncedLyrics) return;
|
||||
const currentMs = this.player.currentTime * 1000;
|
||||
let idx = this.activeLyricIndex;
|
||||
if (idx > this.lyrics.length - 1) {
|
||||
idx = -1;
|
||||
}
|
||||
if (idx >= 0 && this.lyrics.at(idx)?.timestamp > currentMs) {
|
||||
idx = -1;
|
||||
}
|
||||
while (
|
||||
idx + 1 < this.lyrics.length &&
|
||||
this.lyrics.at(idx + 1).timestamp <= currentMs
|
||||
) {
|
||||
idx++;
|
||||
}
|
||||
let first = idx;
|
||||
while (
|
||||
first > 0 &&
|
||||
this.lyrics.at(first - 1)?.timestamp === this.lyrics.at(idx)?.timestamp
|
||||
) {
|
||||
first--;
|
||||
}
|
||||
if (first !== this.activeLyricIndex) {
|
||||
this.activeLyricIndex = first;
|
||||
this.activeWordIndex = -1;
|
||||
}
|
||||
this.syncActiveWord(currentMs);
|
||||
},
|
||||
// Update active word within the active lyric line (for elrc)
|
||||
syncActiveWord(currentMs) {
|
||||
const words = this.activeLyricIndex >= 0 ? this.lyrics.at(this.activeLyricIndex)?.words : null;
|
||||
if (!words?.length) {
|
||||
this.activeWordIndex = -1;
|
||||
return;
|
||||
}
|
||||
let idx = this.activeWordIndex;
|
||||
if (idx > words.length - 1) {
|
||||
idx = -1;
|
||||
}
|
||||
if (idx < 0 || words.at(idx)?.timestamp > currentMs) {
|
||||
idx = 0;
|
||||
}
|
||||
while (idx + 1 < words.length && words.at(idx + 1).timestamp <= currentMs) {
|
||||
idx++;
|
||||
}
|
||||
if (words.at(idx)?.timestamp > currentMs) {
|
||||
idx = -1;
|
||||
}
|
||||
if (idx !== this.activeWordIndex) {
|
||||
this.activeWordIndex = idx;
|
||||
}
|
||||
},
|
||||
scrollMobileLyrics() {
|
||||
if (this.mobileLyricsScrollLocked) return;
|
||||
const el = this.$refs.lyricsMobileScrollable;
|
||||
if (!el) return;
|
||||
const active = el.querySelector('.lyric-line.active');
|
||||
if (active) active.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||
},
|
||||
showToast() {
|
||||
if (this.toastTimeout) {
|
||||
clearTimeout(this.toastTimeout);
|
||||
@@ -2763,27 +2610,37 @@ export default {
|
||||
// This method gets called once only when in the visualizer tab of the audio panel
|
||||
if (this.audioGraphInitialized) return;
|
||||
if (this.previewType !== 'audio') return;
|
||||
if (this.audioContext) {
|
||||
this.cleanupAudioVisualizer();
|
||||
}
|
||||
const audio = this.mediaElement;
|
||||
if (!audio) return;
|
||||
let newContext = null;
|
||||
try {
|
||||
const AudioContextCtor = window.AudioContext || window.webkitAudioContext;
|
||||
if (!AudioContextCtor) return;
|
||||
const ctx = new AudioContextCtor({ latencyHint: 'playback' });
|
||||
const source = ctx.createMediaElementSource(audio);
|
||||
// Connect source to destination
|
||||
source.connect(ctx.destination);
|
||||
this.audioContext = ctx;
|
||||
this.audioSource = source;
|
||||
let graph = this.mediaGraph;
|
||||
if (!(graph && graph.element === audio && graph.context.state !== 'closed')) {
|
||||
if (graph) {
|
||||
this.closeMediaGraph(graph);
|
||||
this.mediaGraph = null;
|
||||
}
|
||||
const AudioContextCtor = window.AudioContext || window.webkitAudioContext;
|
||||
if (!AudioContextCtor) return;
|
||||
newContext = new AudioContextCtor({ latencyHint: 'playback' });
|
||||
const source = newContext.createMediaElementSource(audio);
|
||||
source.connect(newContext.destination);
|
||||
graph = { element: audio, context: newContext, source };
|
||||
this.mediaGraph = graph;
|
||||
newContext = null; // owned by this.mediaGraph from here on
|
||||
}
|
||||
this.audioContext = graph.context;
|
||||
this.audioSource = graph.source;
|
||||
this.audioGraphInitialized = true;
|
||||
} catch (err) {
|
||||
console.warn('Audio visualizer creation failed:', err);
|
||||
if (newContext) {
|
||||
try { newContext.close(); } catch (_) { /* ignore */ }
|
||||
}
|
||||
}
|
||||
},
|
||||
resumeAudioGraph() {
|
||||
const context = this.audioContext;
|
||||
const context = this.mediaGraph?.context;
|
||||
if (context?.state !== 'suspended') return;
|
||||
try {
|
||||
const resumed = context.resume();
|
||||
@@ -2816,7 +2673,6 @@ export default {
|
||||
},
|
||||
timeupdate: () => {
|
||||
this.updateMediaSessionPlaybackState();
|
||||
this.syncLyrics();
|
||||
if (this.transcodePlayback.sessionController) {
|
||||
this.transcodePlayback.updatePlayback({
|
||||
currentTime: this.player?.currentTime,
|
||||
@@ -4554,6 +4410,14 @@ export default {
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.lyrics-mobile {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1 1 0%;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
/* When mobile lyrics are open: push art+meta to top */
|
||||
.audio-player-container--lyrics-open {
|
||||
justify-content: flex-start;
|
||||
@@ -4618,6 +4482,7 @@ export default {
|
||||
background: transparent;
|
||||
border-radius: var(--borderRadius);
|
||||
box-sizing: border-box;
|
||||
scrollbar-width: none;
|
||||
}
|
||||
|
||||
/* --- panel transition --- */
|
||||
@@ -4634,109 +4499,6 @@ export default {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
/* Lyrics */
|
||||
.lyric-line {
|
||||
padding: 0.2em 0;
|
||||
opacity: 0.5;
|
||||
transition: opacity 0.25s ease, color 0.25s ease, font-size 0.25s ease, transform 0.25s ease;
|
||||
transform: scale(1);
|
||||
transform-origin: center;
|
||||
overflow-wrap: break-word;
|
||||
cursor: pointer;
|
||||
font-size: 1.15rem;
|
||||
}
|
||||
|
||||
.lyric-line:hover {
|
||||
opacity: 0.85;
|
||||
}
|
||||
|
||||
.lyric-line.active {
|
||||
opacity: 1;
|
||||
font-weight: 700;
|
||||
color: var(--primaryColor);
|
||||
font-size: 1.35rem;
|
||||
animation: lyric-line-in 0.3s ease;
|
||||
}
|
||||
|
||||
@keyframes lyric-line-in {
|
||||
0% { transform: scale(0.98); }
|
||||
100% { transform: scale(1); }
|
||||
}
|
||||
|
||||
.lyric-word {
|
||||
display: inline-block;
|
||||
opacity: 0.4;
|
||||
transform: scale(1);
|
||||
transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.25, 0.8, 0.25, 1);
|
||||
}
|
||||
|
||||
.lyric-word.sung {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.lyric-word.current {
|
||||
transform: scale(1.06);
|
||||
}
|
||||
|
||||
.lyrics-mobile {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
max-height: 30vh;
|
||||
margin-top: -0.5em;
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
.audio-player-container--lyrics-open .lyrics-mobile {
|
||||
flex: 1 1 0%;
|
||||
min-height: 0;
|
||||
max-height: none;
|
||||
margin-top: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.lyrics-mobile-scrollable {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 0 1em;
|
||||
text-align: center;
|
||||
color: var(--textPrimary);
|
||||
}
|
||||
|
||||
/* Hide scrollbars in lyrics */
|
||||
.lyrics-scrollable,
|
||||
.lyrics-mobile-scrollable,
|
||||
.lyrics-panel {
|
||||
scrollbar-width: none;
|
||||
}
|
||||
|
||||
.lyrics-scrollable::-webkit-scrollbar,
|
||||
.lyrics-mobile-scrollable::-webkit-scrollbar,
|
||||
.lyrics-panel::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.audio-player-container--lyrics-open .lyrics-mobile-scrollable {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.lyrics-mobile-scrollable .lyric-line:first-child {
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
.lyrics-meta-header {
|
||||
padding: 0.2em 0 0.6em;
|
||||
margin: 0;
|
||||
opacity: 0.55;
|
||||
font-size: 0.85rem;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.02em;
|
||||
text-transform: uppercase;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.album-art-container {
|
||||
flex-shrink: 0;
|
||||
border-radius: 1em;
|
||||
|
||||
Reference in new issue
Block a user