Unify playback-state read/write via /api/meta/playback-state
This commit is contained in:
@@ -207,7 +207,6 @@ import {
|
||||
openFolder,
|
||||
isMpcBeReachable,
|
||||
fetchResumePositions,
|
||||
normalizeMediaPath,
|
||||
getPlayerStatus,
|
||||
} from "./api"
|
||||
import { useSettings } from "./composables/useSettings"
|
||||
@@ -547,10 +546,9 @@ async function refreshPlayerStatus() {
|
||||
}
|
||||
}
|
||||
|
||||
function hasResumePosition(filePath: string | null) {
|
||||
if (!filePath) return false
|
||||
const normalizedPath = normalizeMediaPath(filePath)
|
||||
return Number(resumePositions.value[normalizedPath] || 0) > 0
|
||||
function hasResumePosition(mediaId: string | null) {
|
||||
if (!mediaId) return false
|
||||
return Number(resumePositions.value[mediaId] || 0) > 0
|
||||
}
|
||||
|
||||
function startMpcBePolling() {
|
||||
|
||||
+9
-1
@@ -126,7 +126,15 @@ export async function fetchResumePositions(): Promise<Record<string, number>> {
|
||||
if (!positions || typeof positions !== "object") {
|
||||
return {}
|
||||
}
|
||||
return positions as Record<string, number>
|
||||
const normalized: Record<string, number> = {}
|
||||
for (const [slug, value] of Object.entries(positions as Record<string, unknown>)) {
|
||||
if (!value || typeof value !== "object") continue
|
||||
const pos = (value as { pos?: unknown }).pos
|
||||
if (typeof pos === "number" && Number.isFinite(pos) && pos > 0) {
|
||||
normalized[slug] = pos
|
||||
}
|
||||
}
|
||||
return normalized
|
||||
} catch {
|
||||
return {}
|
||||
}
|
||||
|
||||
@@ -256,7 +256,7 @@ const props = defineProps<{
|
||||
item: MediaItem
|
||||
allMovies: MovieUi[]
|
||||
focusEpisode?: { seasonNumber: number; episodeNumber: number } | null
|
||||
hasResumePosition: (filePath: string | null) => boolean
|
||||
hasResumePosition: (mediaId: string | null) => boolean
|
||||
getRootName: (rootId: string | null | undefined) => string | null
|
||||
}>()
|
||||
const emit = defineEmits<{
|
||||
@@ -828,7 +828,8 @@ function closeVersionActionMenu() {
|
||||
}
|
||||
|
||||
function getPlayLabel(filePath: string | null): string {
|
||||
return props.hasResumePosition(filePath) ? "Continue" : "Play"
|
||||
if (!filePath || props.item.type !== "movies") return "Play"
|
||||
return props.hasResumePosition(props.item.id) ? "Continue" : "Play"
|
||||
}
|
||||
|
||||
function handlePlayVersion(filePath: string | null) {
|
||||
|
||||
Reference in New Issue
Block a user