diff options
| author | Paul Buetow <paul@buetow.org> | 2026-04-30 19:24:17 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-04-30 19:24:17 +0300 |
| commit | de7f8603514755032dbaf5dfae8e1cd5f20c1da8 (patch) | |
| tree | 2912afa37e39c8a166bf885c841d6bd292c65133 /web/js/app.js | |
| parent | 5f44e3a65eaae26fe8d551f20f85b75f00ca2d5b (diff) | |
Wire playback resume end to end (task ka)
- Add JSON tags to model structs so API responses use camelCase keys (e.g., id, file_name, position_seconds).
- MediaDetail now includes progress; add ResumeFrom() helper on MediaDetail.
- Frontend playSelected() fetches /api/media/:id and reads progress.position_seconds
before starting playback, then passes resume position to selectAndPlay().
- player.js selectAndPlay/loadMedia accept resumeFrom parameter instead of reading
media.resume_from from list items.
- Backend test coverage: handlers_test verifies detail endpoint returns progress
position in JSON; media_test verifies GetMediaDetail includes progress and
ResumeFrom() value.
- Frontend test coverage: added web/js/tests/playback-resume.test.js validating
detail JSON shape, resume position computation, and list item contract.
Diffstat (limited to 'web/js/app.js')
| -rw-r--r-- | web/js/app.js | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/web/js/app.js b/web/js/app.js index 8e8393e..2238e5b 100644 --- a/web/js/app.js +++ b/web/js/app.js @@ -243,12 +243,19 @@ function renderItem(m, index) { `; } -function playSelected() { +async function playSelected() { const el = currentElement(); if (!el) return; const idx = parseInt(el.dataset.index, 10); const media = state.media[idx]; - if (media) selectAndPlay(media, idx); + if (!media) return; + try { + const detail = await API.mediaDetail(media.id); + const resumeFrom = detail?.progress?.position_seconds ?? 0; + selectAndPlay(media, idx, resumeFrom); + } catch { + selectAndPlay(media, idx, 0); + } } async function shareSelected() { |
