mirror of
https://github.com/gtsteffaniak/filebrowser.git
synced 2026-11-26 08:29:41 -05:00
final fixes
This commit is contained in:
10 files changed
+191
-44
No files matched your search
@@ -9,7 +9,7 @@
|
||||
<PlaybackQueue embedded />
|
||||
</div>
|
||||
<div v-else-if="activeTab === 'lyrics'" class="tab-lyrics">
|
||||
<LyricsList :lyrics="lyrics" :player="player" />
|
||||
<LyricsList v-model:scroll-locked="lyricsScrollLocked" :lyrics="lyrics" :player="player" />
|
||||
</div>
|
||||
<div v-else-if="activeTab === 'visualizer'" ref="visualizerContainer" class="tab-visualizer">
|
||||
<FloatingActionButton
|
||||
@@ -125,6 +125,7 @@ function readStoredTab(): PanelTab {
|
||||
}
|
||||
|
||||
const activeTab = ref<PanelTab>(readStoredTab());
|
||||
const lyricsScrollLocked = ref<boolean | undefined>(false);
|
||||
|
||||
const visualizerContainer = useTemplateRef<HTMLElement>("visualizerContainer");
|
||||
const visualizerCanvas = useTemplateRef<HTMLCanvasElement>("visualizerCanvas");
|
||||
|
||||
@@ -52,6 +52,8 @@ import { useI18n } from "@/i18n/index.ts";
|
||||
import { isSyncedLyrics } from "@/utils/lyrics.ts";
|
||||
import type { LyricLines } from "@/utils/lyrics.ts";
|
||||
|
||||
const scrollLocked = defineModel<boolean>("scrollLocked");
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
lyrics?: LyricLines;
|
||||
@@ -72,7 +74,6 @@ 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)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
v-if="showZone"
|
||||
ref="zoneEl"
|
||||
class="fab-zone"
|
||||
:class="[`fab-zone--${position}`, { 'fab-zone--interactive': interactiveZone, 'fab-zone--fullscreen': fullscreenHost }]"
|
||||
:class="[`fab-zone--${position}`, { 'fab-zone--interactive': interactiveZone, 'fab-zone--fullscreen': fullscreenHost, 'fab-zone--behind-overlay': behindOverlay }]"
|
||||
:style="zoneStyle"
|
||||
@pointerenter="handleZoneEnter"
|
||||
@pointerleave="handleZoneLeave"
|
||||
@@ -20,6 +20,7 @@
|
||||
{
|
||||
'fab-button--extended': extended,
|
||||
'fab-button--fullscreen': fullscreenHost,
|
||||
'fab-button--behind-overlay': behindOverlay,
|
||||
'fab-button--slide-in-visible': topCenterVisible,
|
||||
'fab-button--hidden': autoHide && !showButton,
|
||||
},
|
||||
@@ -178,6 +179,9 @@ export default {
|
||||
isZoneActive(): boolean {
|
||||
return this.sharedState ? this.sharedState.zoneActive : this.buttonZone;
|
||||
},
|
||||
behindOverlay(): boolean {
|
||||
return !!this.fullscreenHost && getters.showOverlay();
|
||||
},
|
||||
showZone(): boolean {
|
||||
return this.autoHide;
|
||||
},
|
||||
@@ -362,6 +366,11 @@ export default {
|
||||
z-index: 10000;
|
||||
}
|
||||
|
||||
.fab-zone--behind-overlay,
|
||||
.fab-zone--behind-overlay.fab-zone--interactive {
|
||||
z-index: 3;
|
||||
}
|
||||
|
||||
.fab-zone--top-right {
|
||||
top: 4em;
|
||||
right: 0;
|
||||
@@ -417,6 +426,10 @@ export default {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.fab-button--behind-overlay {
|
||||
z-index: 3;
|
||||
}
|
||||
|
||||
.fab-button:not(.fab-button--primary) {
|
||||
background: var(--surfacePrimary);
|
||||
}
|
||||
|
||||
@@ -250,6 +250,9 @@ export function useSwipeNavigationGestures({
|
||||
mutations.setNavigationGestureHint({});
|
||||
}
|
||||
function resetEdgeGestureImmediate() {
|
||||
if (gestures.longPressTriggered.value) {
|
||||
releaseLongPressHold();
|
||||
}
|
||||
resetSwipeVisualState();
|
||||
gestures.clearEdgeTapGestureState();
|
||||
gestures.clearSkipNextTap();
|
||||
@@ -396,7 +399,7 @@ export function useSwipeNavigationGestures({
|
||||
document.addEventListener('mouseup', onSwipeMouseDocUp, true);
|
||||
}
|
||||
function onSwipeTouchStart(event: TouchEvent) {
|
||||
if (event.targetTouches.length > 1) {
|
||||
if (event.touches.length > 1) {
|
||||
gestures.clearLongPressTimer();
|
||||
gestures.longPressPending.value = false;
|
||||
if (!gestures.longPressTriggered.value) {
|
||||
@@ -404,7 +407,7 @@ export function useSwipeNavigationGestures({
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!swipeGesturesActive.value || event.targetTouches.length !== 1) return;
|
||||
if (!swipeGesturesActive.value || event.touches.length !== 1) return;
|
||||
swipeActiveTouchId = null;
|
||||
// Don't start a gesture if we are selecting some text
|
||||
if ((window.getSelection()?.toString().length ?? 0) > 0) return;
|
||||
@@ -508,6 +511,13 @@ export function useSwipeNavigationGestures({
|
||||
}
|
||||
function onSwipeTouchEnd(event: TouchEvent) {
|
||||
if (!swipeGesturesActive.value) {
|
||||
if (
|
||||
gestures.longPressPending.value &&
|
||||
findTouchById(event.changedTouches, swipeActiveTouchId)
|
||||
) {
|
||||
gestures.clearLongPressTimer();
|
||||
gestures.longPressPending.value = false;
|
||||
}
|
||||
if (
|
||||
gestures.longPressTriggered.value &&
|
||||
findTouchById(event.changedTouches, swipeActiveTouchId)
|
||||
|
||||
@@ -165,6 +165,10 @@ export function useTranscodePlayback(options: UseTranscodePlaybackOptions) {
|
||||
const transcodeOffer = ref<TranscodeOffer | null>(null);
|
||||
/** The user accepted the offer: play through transcoding from the start. */
|
||||
const startRequested = ref(false);
|
||||
/** The user paused before a profile change: keep it paused through native attachment */
|
||||
const profileChangePaused = ref(false);
|
||||
/** The offer whose acceptance is awaiting its status lookup */
|
||||
let pendingAcceptance: TranscodeOffer | null = null;
|
||||
const transcodeClientId = createTranscodeClientId();
|
||||
|
||||
let attachVideoStreamResume: (() => void) | null = null;
|
||||
@@ -235,7 +239,7 @@ export function useTranscodePlayback(options: UseTranscodePlaybackOptions) {
|
||||
if (isTranscodeHlsMode(transcodeMode.value) || transcodeStartInProgress.value) {
|
||||
return false;
|
||||
}
|
||||
if (formatNeedsTranscode.value) {
|
||||
if (formatNeedsTranscode.value || profileChangePaused.value) {
|
||||
return false;
|
||||
}
|
||||
if (resumeShouldAutoplay.value) {
|
||||
@@ -603,7 +607,14 @@ export function useTranscodePlayback(options: UseTranscodePlaybackOptions) {
|
||||
if (transcodeOfferEmitted) {
|
||||
return;
|
||||
}
|
||||
if (getters.isShare() || (!confirmedFailure && !formatNeedsTranscode.value)) {
|
||||
if (getters.isShare()) {
|
||||
// Shares cannot transcode
|
||||
if (confirmedFailure || formatNeedsTranscode.value) {
|
||||
notify.showError(t("player.transcodeUnsupportedFormat"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!confirmedFailure && !formatNeedsTranscode.value) {
|
||||
return;
|
||||
}
|
||||
transcodeOfferEmitted = true;
|
||||
@@ -1085,6 +1096,7 @@ export function useTranscodePlayback(options: UseTranscodePlaybackOptions) {
|
||||
invalidateOfferRequest();
|
||||
const previousMode = transcodeMode.value;
|
||||
const wasPlaying = !!player.value?.playing;
|
||||
profileChangePaused.value = !wasPlaying;
|
||||
transcodeLog("switchTranscodeMode start", {
|
||||
mode,
|
||||
previousMode,
|
||||
@@ -1113,7 +1125,7 @@ export function useTranscodePlayback(options: UseTranscodePlaybackOptions) {
|
||||
replaceSessionId,
|
||||
startSec: player.value?.currentTime ?? 0,
|
||||
mode,
|
||||
autoplay: wasPlaying || shouldAutoplay.value,
|
||||
autoplay: wasPlaying,
|
||||
playPrime: wasPlaying ? playPrime : null,
|
||||
manageSwitchState: false,
|
||||
});
|
||||
@@ -1122,16 +1134,18 @@ export function useTranscodePlayback(options: UseTranscodePlaybackOptions) {
|
||||
teardownTranscodePlayback({ stopSession: true });
|
||||
try {
|
||||
const status = await getTranscodeSessions();
|
||||
showTranscodeOffer(normalizeTranscodeSessionStatus(status, {
|
||||
source: getReq()?.source,
|
||||
path: getReq()?.path,
|
||||
}),
|
||||
);
|
||||
if (generation === fileGeneration) {
|
||||
showTranscodeOffer(normalizeTranscodeSessionStatus(status, {
|
||||
source: getReq()?.source,
|
||||
path: getReq()?.path,
|
||||
}),
|
||||
);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("Failed to check transcode sessions:", err);
|
||||
}
|
||||
} else {
|
||||
await switchToNativePlayback({ autoplay: wasPlaying || shouldAutoplay.value });
|
||||
await switchToNativePlayback({ autoplay: wasPlaying });
|
||||
}
|
||||
onModeMenuChange();
|
||||
} catch (err) {
|
||||
@@ -1148,7 +1162,9 @@ export function useTranscodePlayback(options: UseTranscodePlaybackOptions) {
|
||||
}
|
||||
} finally {
|
||||
transcodeSwitchInProgress.value = false;
|
||||
syncPlaybackUrl({ transcodeMode: transcodeMode.value });
|
||||
if (generation === fileGeneration) {
|
||||
syncPlaybackUrl({ transcodeMode: transcodeMode.value });
|
||||
}
|
||||
transcodeLog("switchTranscodeMode done", {
|
||||
mode: transcodeMode.value,
|
||||
transcodeActive: transcodeActive.value,
|
||||
@@ -1256,6 +1272,11 @@ export function useTranscodePlayback(options: UseTranscodePlaybackOptions) {
|
||||
transcodeOffer.value = null;
|
||||
return false;
|
||||
}
|
||||
const offer = transcodeOffer.value;
|
||||
if (offer && pendingAcceptance === offer) {
|
||||
return false;
|
||||
}
|
||||
pendingAcceptance = offer;
|
||||
try {
|
||||
const status = normalizeTranscodeSessionStatus(await getTranscodeSessions(), {
|
||||
source: getReq()?.source,
|
||||
@@ -1276,6 +1297,10 @@ export function useTranscodePlayback(options: UseTranscodePlaybackOptions) {
|
||||
} catch (err) {
|
||||
console.error("Failed to verify transcode availability:", err);
|
||||
return false;
|
||||
} finally {
|
||||
if (pendingAcceptance === offer) {
|
||||
pendingAcceptance = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1289,6 +1314,8 @@ export function useTranscodePlayback(options: UseTranscodePlaybackOptions) {
|
||||
resumeSnapshot.value = null;
|
||||
resumeSeekSeconds.value = null;
|
||||
lockedNativeVideoSrc.value = null;
|
||||
profileChangePaused.value = false;
|
||||
pendingAcceptance = null;
|
||||
transcodeOfferEmitted = false;
|
||||
transcodeFallbackAttempted = false;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ const MAX_SEEK_WARMUP_MS = 45_000;
|
||||
const ATTACH_STALL_TIMEOUT_MS = 30_000;
|
||||
const FRAG_FIRST_BYTE_TIMEOUT_MS = 45_000;
|
||||
const ATTACH_STARTUP_STALL_TIMEOUT_MS = FRAG_FIRST_BYTE_TIMEOUT_MS;
|
||||
const FRAG_MAX_LOAD_MS = 120_000;
|
||||
|
||||
/**
|
||||
* Total attach budget for a start position: the base deadline plus a bounded
|
||||
@@ -196,7 +197,17 @@ function describeHlsError(data) {
|
||||
};
|
||||
}
|
||||
|
||||
function attachNativeHls({ video, playlistURL, initialStart, signal, onFirstBuffered, budgetMs }) {
|
||||
function attachNativeHls({
|
||||
video,
|
||||
playlistURL,
|
||||
initialStart,
|
||||
signal,
|
||||
onFirstBuffered,
|
||||
budgetMs,
|
||||
sessionId,
|
||||
onFatal,
|
||||
onRecoverPlayback,
|
||||
}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const deadlineMs = resolveAttachDeadlineMs(initialStart, budgetMs);
|
||||
let settled = false;
|
||||
@@ -207,7 +218,6 @@ function attachNativeHls({ video, playlistURL, initialStart, signal, onFirstBuff
|
||||
signal?.removeEventListener('abort', onAbort);
|
||||
video.removeEventListener('loadeddata', onReady);
|
||||
video.removeEventListener('canplay', onReady);
|
||||
video.removeEventListener('error', onError);
|
||||
};
|
||||
const releaseSource = () => {
|
||||
video.removeAttribute('src');
|
||||
@@ -215,6 +225,7 @@ function attachNativeHls({ video, playlistURL, initialStart, signal, onFirstBuff
|
||||
};
|
||||
const cleanup = () => {
|
||||
removeListeners();
|
||||
video.removeEventListener('error', onError);
|
||||
releaseSource();
|
||||
};
|
||||
const fail = (error) => {
|
||||
@@ -242,8 +253,31 @@ function attachNativeHls({ video, playlistURL, initialStart, signal, onFirstBuff
|
||||
const error = new Error(mediaError?.message || 'Native HLS playback failed');
|
||||
error.name = 'NativeHlsError';
|
||||
error.code = mediaError?.code;
|
||||
if (settled) {
|
||||
reportPostReadyError(error);
|
||||
return;
|
||||
}
|
||||
fail(error);
|
||||
}
|
||||
function reportPostReadyError(error) {
|
||||
const data = { fatal: true, type: 'mediaError', details: 'nativeHlsError', code: error.code, reason: error.message };
|
||||
const startSec = Number.isFinite(video.currentTime) ? video.currentTime : 0;
|
||||
const shouldAutoplay = !video.paused && !video.ended;
|
||||
cleanup();
|
||||
if (error.code === MediaError.MEDIA_ERR_NETWORK && onRecoverPlayback) {
|
||||
void onRecoverPlayback({ startSec, sessionId, shouldAutoplay })
|
||||
.then((ok) => {
|
||||
if (!ok) {
|
||||
onFatal?.(data);
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
onFatal?.(data);
|
||||
});
|
||||
return;
|
||||
}
|
||||
onFatal?.(data);
|
||||
}
|
||||
function onTimeout() {
|
||||
transcodeError('native hls attach timed out waiting for readiness', {
|
||||
playlistURL,
|
||||
@@ -328,6 +362,9 @@ export function attachHlsToVideo({
|
||||
signal,
|
||||
onFirstBuffered,
|
||||
budgetMs,
|
||||
sessionId: session?.id,
|
||||
onFatal,
|
||||
onRecoverPlayback,
|
||||
});
|
||||
}
|
||||
return Promise.reject(new Error('HLS not supported in this browser'));
|
||||
@@ -341,6 +378,7 @@ export function attachHlsToVideo({
|
||||
return new Promise((resolve, reject) => {
|
||||
let settled = false;
|
||||
let readyToPlay = false;
|
||||
let startApplied = false;
|
||||
let bufferedFrags = 0;
|
||||
// The synthetic VOD playlist lists the full media duration; a single
|
||||
// buffered fragment is enough to start playback.
|
||||
@@ -353,7 +391,7 @@ export function attachHlsToVideo({
|
||||
if (!onRecoverPlayback || destroyed) {
|
||||
return false;
|
||||
}
|
||||
const playbackStarted = readyToPlay;
|
||||
const playbackStarted = startApplied;
|
||||
const currentTime = video?.currentTime;
|
||||
const resumeAt = playbackStarted && Number.isFinite(currentTime)
|
||||
? currentTime
|
||||
@@ -447,6 +485,17 @@ export function attachHlsToVideo({
|
||||
: ATTACH_STARTUP_STALL_TIMEOUT_MS;
|
||||
stallTimeoutId = setTimeout(onAttachTimeout, Math.min(limitMs, remaining));
|
||||
};
|
||||
const noteFragmentResponseStarted = () => {
|
||||
if (settled) {
|
||||
return;
|
||||
}
|
||||
clearTimeout(stallTimeoutId);
|
||||
const remaining = deadlineMs - (performance.now() - attachStartedAt);
|
||||
if (remaining <= 0) {
|
||||
return;
|
||||
}
|
||||
stallTimeoutId = setTimeout(onAttachTimeout, Math.min(FRAG_MAX_LOAD_MS, remaining));
|
||||
};
|
||||
|
||||
let appendRecoveryAttempts = 0;
|
||||
const startPlaybackReady = (reason) => {
|
||||
@@ -473,6 +522,7 @@ export function attachHlsToVideo({
|
||||
});
|
||||
}
|
||||
onFirstBuffered?.(video);
|
||||
startApplied = true;
|
||||
finish('resolve', { cleanup, hls });
|
||||
});
|
||||
};
|
||||
@@ -510,7 +560,7 @@ export function attachHlsToVideo({
|
||||
// well past hls.js's 10s default. Aborting at 10s cancelled the
|
||||
// request server-side and surfaced as a 503 + skipped segment.
|
||||
maxTimeToFirstByteMs: FRAG_FIRST_BYTE_TIMEOUT_MS,
|
||||
maxLoadTimeMs: 120_000,
|
||||
maxLoadTimeMs: FRAG_MAX_LOAD_MS,
|
||||
timeoutRetry: {
|
||||
maxNumRetry: 4,
|
||||
retryDelayMs: 1000,
|
||||
@@ -529,6 +579,13 @@ export function attachHlsToVideo({
|
||||
xhr.setRequestHeader(key, value);
|
||||
}
|
||||
transcodeVerbose('hls xhr open', { url });
|
||||
if (!/\.m3u8(\?|$)/.test(url)) {
|
||||
xhr.addEventListener('readystatechange', () => {
|
||||
if (xhr.readyState === XMLHttpRequest.HEADERS_RECEIVED && xhr.status >= 200 && xhr.status < 300) {
|
||||
noteFragmentResponseStarted();
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
fetchSetup(context, initParams) {
|
||||
transcodeVerbose('hls fetch setup', { url: context?.url });
|
||||
|
||||
@@ -669,15 +669,18 @@ export function enableScrubPreview(player, options) {
|
||||
|
||||
// Same bucket — only reposition the popup, no image/time churn.
|
||||
if (percentInt === displayedPercent) {
|
||||
pendingPercent = percentInt;
|
||||
pendingVisualPercent = null;
|
||||
const displayedSrc = cache.get(displayedPercent);
|
||||
if (displayedSrc && img.src !== displayedSrc) {
|
||||
applyCachedImage(percentInt);
|
||||
if (displayedSrc) {
|
||||
pendingPercent = percentInt;
|
||||
pendingVisualPercent = null;
|
||||
if (img.src !== displayedSrc) {
|
||||
applyCachedImage(percentInt);
|
||||
return;
|
||||
}
|
||||
setLoading(false);
|
||||
return;
|
||||
}
|
||||
setLoading(false);
|
||||
return;
|
||||
displayedPercent = null;
|
||||
}
|
||||
|
||||
pendingPercent = percentInt;
|
||||
|
||||
@@ -67,6 +67,8 @@ interface CommittedSource {
|
||||
raw: string;
|
||||
subtitles: SubtitleSource[];
|
||||
lyrics: LyricLines;
|
||||
subtitleInputs: string | null;
|
||||
lyricsInputs: string | null;
|
||||
}
|
||||
|
||||
function revokeSubtitleUrls(tracks: readonly SubtitleSource[]): void {
|
||||
@@ -268,17 +270,22 @@ async function loadAndCommit(identity: string, isStale: () => boolean) {
|
||||
}
|
||||
|
||||
const kind = previewType.value as "audio" | "video";
|
||||
// the same file again (e.g. a late metadata patch) keeps its subtitles and lyrics
|
||||
const current = committed.value;
|
||||
const reuse = current?.key === identity && current.kind === kind ? current : null;
|
||||
const loadedSubtitles = reuse ? reuse.subtitles : await subtitles(isStale);
|
||||
const subtitleInputs = JSON.stringify((state.req.subtitles ?? []).map((track) => [track?.name, track?.embedded]));
|
||||
const lyricsInputs = kind === "audio" && state.req.metadata?.hasLyrics ? "lyrics" : "";
|
||||
const reuseSubtitles = reuse?.subtitleInputs === subtitleInputs ? reuse : null;
|
||||
const reuseLyrics = reuse?.lyricsInputs === lyricsInputs ? reuse : null;
|
||||
const subtitlesOutcome = { failed: false };
|
||||
const lyricsOutcome = { failed: false };
|
||||
const loadedSubtitles = reuseSubtitles ? reuseSubtitles.subtitles : await subtitles(isStale, subtitlesOutcome);
|
||||
if (isStale()) {
|
||||
if (!reuse) revokeSubtitleUrls(loadedSubtitles);
|
||||
if (!reuseSubtitles) revokeSubtitleUrls(loadedSubtitles);
|
||||
return;
|
||||
}
|
||||
const loadedLyrics = reuse ? reuse.lyrics : kind === "audio" ? await loadLyrics() : [];
|
||||
const loadedLyrics = reuseLyrics ? reuseLyrics.lyrics : kind === "audio" ? await loadLyrics(lyricsOutcome) : [];
|
||||
if (isStale()) {
|
||||
if (!reuse) revokeSubtitleUrls(loadedSubtitles);
|
||||
if (!reuseSubtitles) revokeSubtitleUrls(loadedSubtitles);
|
||||
return;
|
||||
}
|
||||
commitSource({
|
||||
@@ -288,12 +295,14 @@ async function loadAndCommit(identity: string, isStale: () => boolean) {
|
||||
raw: buildRaw(),
|
||||
subtitles: loadedSubtitles,
|
||||
lyrics: loadedLyrics,
|
||||
subtitleInputs: subtitlesOutcome.failed ? null : subtitleInputs,
|
||||
lyricsInputs: lyricsOutcome.failed ? null : lyricsInputs,
|
||||
});
|
||||
avMetadataLoading.value = false;
|
||||
selectCurrentItem();
|
||||
}
|
||||
|
||||
async function loadLyrics(): Promise<LyricLines> {
|
||||
async function loadLyrics(outcome: { failed: boolean }): Promise<LyricLines> {
|
||||
if (!state.req.metadata?.hasLyrics) {
|
||||
return [];
|
||||
}
|
||||
@@ -302,6 +311,7 @@ async function loadLyrics(): Promise<LyricLines> {
|
||||
return parseLyrics(rawLyrics, format);
|
||||
} catch (err) {
|
||||
console.warn("Failed to fetch lyrics:", err);
|
||||
outcome.failed = true;
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -335,7 +345,7 @@ async function enrichAvFromMediaApi(isStale: () => boolean): Promise<boolean> {
|
||||
return false;
|
||||
}
|
||||
|
||||
async function subtitles(isStale: () => boolean): Promise<SubtitleSource[]> {
|
||||
async function subtitles(isStale: () => boolean, outcome: { failed: boolean }): Promise<SubtitleSource[]> {
|
||||
const source = state.req.source as string;
|
||||
const path = state.req.path as string;
|
||||
const tracks = [...(state.req.subtitles ?? [])];
|
||||
@@ -384,6 +394,7 @@ async function subtitles(isStale: () => boolean): Promise<SubtitleSource[]> {
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("Failed to load subtitle:", subtitleTrack.name, err);
|
||||
outcome.failed = true;
|
||||
}
|
||||
}
|
||||
return subs;
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, watch } from "vue";
|
||||
import { computed, onBeforeUnmount, watch } from "vue";
|
||||
import { resourcesApi } from "@/api/index.js";
|
||||
import LoadingSpinner from "@/components/LoadingSpinner.vue";
|
||||
import PreviewNotice from "@/components/files/PreviewNotice.vue";
|
||||
@@ -97,6 +97,9 @@ const pdfConvertable = computed(() => {
|
||||
const isHeicAndViewable = computed(() => state.isSafari || Boolean(state.req?.hasPreview));
|
||||
|
||||
const showImage = computed(() => {
|
||||
if (getters.fileViewingDisabled(state.req.name ?? "")) {
|
||||
return false;
|
||||
}
|
||||
if (state.req.type === "image/heic" || state.req.type === "image/heif") {
|
||||
return isHeicAndViewable.value;
|
||||
}
|
||||
@@ -164,20 +167,30 @@ function openSlideshowOptions() {
|
||||
});
|
||||
}
|
||||
|
||||
let loadOwner = 0;
|
||||
|
||||
async function loadPreviewForReq() {
|
||||
if (!getters.isLoggedIn() && !getters.isShare()) {
|
||||
return;
|
||||
}
|
||||
const owner = ++loadOwner;
|
||||
const path = state.req.path;
|
||||
await loadListingContext();
|
||||
|
||||
if (state.req.path !== path) {
|
||||
if (owner !== loadOwner || state.req.path !== path) {
|
||||
return;
|
||||
}
|
||||
await updatePreview();
|
||||
if (owner !== loadOwner) {
|
||||
return;
|
||||
}
|
||||
selectCurrentItem();
|
||||
}
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
loadOwner += 1;
|
||||
});
|
||||
|
||||
watch(
|
||||
() => state.req,
|
||||
async () => {
|
||||
|
||||
@@ -140,21 +140,32 @@ async function tagPlayerElements(page: import("@playwright/test").Page) {
|
||||
}
|
||||
|
||||
async function expectPlayerReused(page: import("@playwright/test").Page, fileName: string) {
|
||||
await waitForNativePlayerMounted(page);
|
||||
await startNativeVideoPlayback(page);
|
||||
const video = nativeVideo(page);
|
||||
const srcMatches = (el: HTMLVideoElement, name: string) => {
|
||||
const src = el.currentSrc || el.getAttribute("src") || "";
|
||||
try {
|
||||
return decodeURIComponent(src).includes(name);
|
||||
} catch {
|
||||
return src.includes(name);
|
||||
}
|
||||
};
|
||||
await expect.poll(() => video.evaluate(srcMatches, fileName), { timeout: 15_000 }).toBe(true);
|
||||
const startTime = await video.evaluate((el: HTMLVideoElement) => el.currentTime);
|
||||
await expect
|
||||
.poll(
|
||||
() =>
|
||||
nativeVideo(page).evaluate((el: HTMLVideoElement) => {
|
||||
const src = el.currentSrc || el.getAttribute("src") || "";
|
||||
try {
|
||||
return decodeURIComponent(src);
|
||||
} catch {
|
||||
return src;
|
||||
}
|
||||
}),
|
||||
{ timeout: 15_000 },
|
||||
video.evaluate(
|
||||
(el: HTMLVideoElement, [name, from]: [string, number]) => {
|
||||
const src = decodeURIComponent(el.currentSrc || el.getAttribute("src") || "");
|
||||
return src.includes(name) && !el.paused && el.currentTime > from + 0.05;
|
||||
},
|
||||
[fileName, startTime] as [string, number],
|
||||
),
|
||||
{ timeout: 15_000, intervals: [100, 250, 500] },
|
||||
)
|
||||
.toContain(fileName);
|
||||
.toBe(true);
|
||||
await expect(page.locator(".media-player video")).toHaveCount(1);
|
||||
await expect(nativeVideo(page)).toHaveAttribute("data-reuse-probe", "1");
|
||||
await expect(page.locator(".media-player .plyr[data-reuse-probe='1']")).toHaveCount(1);
|
||||
|
||||
Reference in new issue
Block a user