添加跳过片头片尾功能

This commit is contained in:
truewhile
2026-09-23 10:22:13 +08:00
parent 016c6687e9
commit 94ef0116b1
26 changed files with 2115 additions and 4 deletions
+8 -1
View File
@@ -1,5 +1,5 @@
import { api } from './client'
import type { Media, Playlist } from '../types'
import type { Media, PlaybackSegmentsResponse, Playlist } from '../types'
// History rows arrive joined with their Media row; the backend returns null
// for orphaned rows whose media has been removed.
@@ -47,6 +47,13 @@ export const playbackAPI = {
.get<{ position_ms: number; duration_ms: number; completed: boolean }>(`/playback/${mediaId}/resume`)
.then((r) => r.data),
// 片头/片尾片段:播放开始后再调用,服务端可能需要几秒去外部数据库取数,
// 因此绝不能让它挡在起播路径上。
segments: (mediaId: string) =>
api
.get<PlaybackSegmentsResponse>(`/playback/${encodeURIComponent(mediaId)}/segments`)
.then((r) => r.data),
recordProgress: (payload: PlaybackProgressRequest) =>
api.post('/history', payload).then((r) => r.data),